Base class for all non built-in types.
Every class which is not a built-in type inherits from this class. You can construct Objects from scripting languages, using [code]Object.new()[/code] in GDScript, [code]new Object[/code] in C#, or the "Construct Object" node in VisualScript. Objects do not manage memory. If a class inherits from Object, you will have to delete instances of it manually. To do so, call the [method free] method from your script or delete the instance from C++. Some classes that extend Object add memory management. This is the case of [Reference], which counts references and deletes itself automatically when no longer referenced. [Node], another fundamental type, deletes all its children when freed from memory. Objects export properties, which are mainly useful for storage and editing, but not really so much in programming. Properties are exported in [method _get_property_list] and handled in [method _get] and [method _set]. However, scripting languages and C++ have simpler means to export them. Objects also receive notifications. Notifications are a simple way to notify the object about different events, so they can all be handled together. See [method _notification].
Virtual method which can be overridden to customize the return value of [method get]. Returns the given property. Returns [code]null[/code] if the [code]property[/code] does not exist.
Virtual method which can be overridden to customize the return value of [method get_property_list]. Returns the object's property list as an [Array] of dictionaries. Each property's [Dictionary] must contain at least [code]name: String[/code] and [code]type: int[/code] (see [enum @GlobalScope.Variant.Type]) entries. Optionally, it can also include [code]hint: int[/code] (see [enum @GlobalScope.PropertyHint]), [code]hint_string: String[/code], and [code]usage: int[/code] (see [enum @GlobalScope.PropertyUsageFlags]).
Called when the object is initialized.
Called whenever the object receives a notification, which is identified in [code]what[/code] by a constant. The base [Object] has two constants [constant NOTIFICATION_POSTINITIALIZE] and [constant NOTIFICATION_PREDELETE], but subclasses such as [Node] define a lot more notifications which are also received by this method.
Virtual method which can be overridden to customize the return value of [method set]. Sets a property. Returns [code]true[/code] if the [code]property[/code] exists.
Adds a user-defined [code]signal[/code]. Arguments are optional, but can be added as an [Array] of dictionaries, each containing [code]name: String[/code] and [code]type: int[/code] (see [enum @GlobalScope.Variant.Type]) entries.
Calls the [code]method[/code] on the object and returns the result. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: [codeblock] call("set", "position", Vector2(42.0, 0.0)) [/codeblock]
Calls the [code]method[/code] on the object during idle time and returns the result. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: [codeblock] call_deferred("set", "position", Vector2(42.0, 0.0)) [/codeblock]
Calls the [code]method[/code] on the object and returns the result. Contrarily to [method call], this method does not support a variable number of arguments but expected all parameters passed via a single [Array]. [codeblock] callv("set", [ "position", Vector2(42.0, 0.0) ]) [/codeblock]
Returns [code]true[/code] if the object can translate strings. See [method set_message_translation] and [method tr].
Connects a [code]signal[/code] to a [code]method[/code] on a [code]target[/code] object. Pass optional [code]binds[/code] to the call as an [Array] of parameters. Use [code]flags[/code] to set deferred or one shot connections. See [enum ConnectFlags] constants. A [code]signal[/code] can only be connected once to a [code]method[/code]. It will throw an error if already connected, unless the signal was connected with [constant CONNECT_REFERENCE_COUNTED]. To avoid this, first, use [method is_connected] to check for existing connections. If the [code]target[/code] is destroyed in the game's lifecycle, the connection will be lost. Examples: [codeblock] connect("pressed", self, "_on_Button_pressed") # BaseButton signal connect("text_entered", self, "_on_LineEdit_text_entered") # LineEdit signal connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # User-defined signal [/codeblock]
Disconnects a [code]signal[/code] from a [code]method[/code] on the given [code]target[/code]. If you try to disconnect a connection that does not exist, the method will throw an error. Use [method is_connected] to ensure that the connection exists.
Emits the given [code]signal[/code]. The signal must exist, so it should be a built-in signal of this class or one of its parent classes, or a user-defined signal. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: [codeblock] emit_signal("hit", weapon_type, damage) emit_signal("game_over") [/codeblock]
Deletes the object from memory. Any pre-existing reference to the freed object will now return [code]null[/code].
Returns the [Variant] value of the given [code]property[/code].
Returns the object's class as a [String].
Returns an [Array] of dictionaries with information about signals that are connected to the object. Each [Dictionary] contains three String entries: - [code]source[/code] is a reference to the signal emitter. - [code]signal_name[/code] is the name of the connected signal. - [code]method_name[/code] is the name of the method to which the signal is connected.
Get the object's property indexed by the given [NodePath]. The node path should be relative to the current object and can use the colon character ([code]:[/code]) to access nested properties. Examples: [code]"position:x"[/code] or [code]"material:next_pass:blend_mode"[/code].
Returns the object's unique instance ID. This ID can be saved in [EncodedObjectAsID], and can be used to retrieve the object instance with [method @GDScript.instance_from_id].
Returns the object's metadata entry for the given [code]name[/code].
Returns the object's metadata as a [PoolStringArray].
Returns the object's methods and their signatures as an [Array].
Returns the object's property list as an [Array] of dictionaries. Each property's [Dictionary] contain at least [code]name: String[/code] and [code]type: int[/code] (see [enum @GlobalScope.Variant.Type]) entries. Optionally, it can also include [code]hint: int[/code] (see [enum @GlobalScope.PropertyHint]), [code]hint_string: String[/code], and [code]usage: int[/code] (see [enum @GlobalScope.PropertyUsageFlags]).
Returns the object's [Script] instance, or [code]null[/code] if none is assigned.
Returns an [Array] of connections for the given [code]signal[/code].
Returns the list of signals as an [Array] of dictionaries.
Returns [code]true[/code] if a metadata entry is found with the given [code]name[/code].
Returns [code]true[/code] if the object contains the given [code]method[/code].
Returns [code]true[/code] if the given user-defined [code]signal[/code] exists.
Returns [code]true[/code] if signal emission blocking is enabled.
Returns [code]true[/code] if the object inherits from the given [code]class[/code].
Returns [code]true[/code] if a connection exists for a given [code]signal[/code], [code]target[/code], and [code]method[/code].
Returns [code]true[/code] if the [method Node.queue_free] method was called for the object.
Send a given notification to the object, which will also trigger a call to the [method _notification] method of all classes that the object inherits from. If [code]reversed[/code] is [code]true[/code], [method _notification] is called first on the object's own class, and then up to its successive parent classes. If [code]reversed[/code] is [code]false[/code], [method _notification] is called first on the highest ancestor ([Object] itself), and then down to its successive inheriting classes.
Notify the editor that the property list has changed, so that editor plugins can take the new values into account. Does nothing on export builds.
Assigns a new value to the given property. If the [code]property[/code] does not exist, nothing will happen.
If set to [code]true[/code], signal emission is blocked.
Assigns a new value to the given property, after the current frame's physics step. This is equivalent to calling [method set] via [method call_deferred], i.e. [code]call_deferred("set", property, value)[/code].
Assigns a new value to the property identified by the [NodePath]. The node path should be relative to the current object and can use the colon character ([code]:[/code]) to access nested properties. Example: [codeblock] set_indexed("position", Vector2(42, 0)) set_indexed("position:y", -10) print(position) # (42, -10) [/codeblock]
Defines whether the object can translate strings (with calls to [method tr]). Default is [code]true[/code].
Adds or changes a given entry in the object's metadata. Metadata are serialized, and can take any [Variant] value.
Assigns a script to the object. Each object can have a single script assigned to it, which are used to extend its functionality.
Translates a message using translation catalogs configured in the Project Settings. Only works if message translation is enabled (which it is by default), otherwise it returns the [code]message[/code] unchanged. See [method set_message_translation].
Emitted whenever the object's script is changed.
Called right when the object is initialized. Not available in script.
Called before the object is about to be deleted.
Connect a signal in deferred mode. This way, signal emissions are stored in a queue, then set on idle time.
Persisting connections are saved when the object is serialized to file.
One shot connections disconnect themselves after emission.
Connect a signal as reference counted. This means that a given signal can be connected several times to the same target, and will only be fully disconnected once no references are left.