Base class for all non built-in types.
    public class Object : IDisposable

Every class which is not a built-in type inherits from this class.

You can construct Objects from scripting languages, using Object.new() in GDScript, new Object 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 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 _GetPropertyList() and handled in _Get(string) and _Set(string, object). 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 _Notification(int).

Inheritance Chain

Derived Classes

Static Fields

    public const Int32 NotificationPostinitialize = 0

    public const Int32 NotificationPredelete = 1

Static Methods

    public static bool IsInstanceValid(Object instance)

    public static WeakRef WeakRef(Object obj)

Constructors

    public Object()

Signals

    "script_changed" ()

Emitted whenever the object’s script is changed.

Properties

    public dynamic DynamicObject { get; }

    public IntPtr NativeInstance { get; }

Methods

    public virtual object _Get(string property)

Virtual method which can be overridden to customize the return value of _Get(string).

Returns the given property. Returns null if the property does not exist.

    public virtual Godot.Collections.Array _GetPropertyList()

Virtual method which can be overridden to customize the return value of _GetPropertyList().

Returns the object’s property list as an Array of dictionaries.

Each property’s Dictionary must contain at least name: String and type: int (see Variant.Type) entries. Optionally, it can also include hint: int (see [enum PropertyHint]), hint_string: String, and usage: int (see [enum PropertyUsageFlags]).

    public virtual void _Notification(int what)

Called whenever the object receives a notification, which is identified in what 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.

    public virtual bool _Set(string property, object value)

Virtual method which can be overridden to customize the return value of _Set(string, object).

Sets a property. Returns true if the property exists.

    public void AddUserSignal(string signal, Godot.Collections.Array arguments = null)

Adds a user-defined signal. Arguments are optional, but can be added as an Array of dictionaries, each containing name: String and type: int (see Variant.Type) entries.

    public object Call(string method, params object[] args)

    public object CallDeferred(string method, params object[] args)

    public object Callv(string method, Godot.Collections.Array argArray)

Calls the method on the object and returns the result. Contrarily to Call(string, params object[]), this method does not support a variable number of arguments but expects all parameters to be via a single Array.

[codeblock]

callv(“set”, [ “position”, Vector2(42.0, 0.0) ])

[/codeblock]

    public bool CanTranslateMessages()

Returns true if the object can translate strings. See SetMessageTranslation(bool) and Tr(string).

    public Error Connect(string signal, Object target, string method, Godot.Collections.Array binds = null, uint flags = 0u)

    public void Disconnect(string signal, Object target, string method)

Disconnects a signal from a method on the given target.

If you try to disconnect a connection that does not exist, the method will throw an error. Use IsConnected(string, Godot.Object, string) to ensure that the connection exists.

    public void Dispose()

    protected virtual void Dispose(bool disposing)

    public object EmitSignal(string signal, params object[] args)

    public void Free()

Deletes the object from memory. Any pre-existing reference to the freed object will now return null.

    public object Get(string property)

Returns the Variant value of the given property.

    public string GetClass()

Returns the object’s class as a String.

    public Godot.Collections.Array GetIncomingConnections()

Returns an Array of dictionaries with information about signals that are connected to the object.

Each Dictionary contains three String entries:

  • source is a reference to the signal emitter.

  • signal_name is the name of the connected signal.

  • method_name is the name of the method to which the signal is connected.

    public object GetIndexed(NodePath property)

Gets 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 (:) to access nested properties. Examples: "position:x" or "material:next_pass:blend_mode".

    public ulong GetInstanceId()

    public object GetMeta(string name)

Returns the object’s metadata entry for the given name.

    public string[] GetMetaList()

Returns the object’s metadata as a PoolStringArray.

    public Godot.Collections.Array GetMethodList()

Returns the object’s methods and their signatures as an Array.

    public Godot.Collections.Array GetPropertyList()

Returns the object’s property list as an Array of dictionaries.

Each property’s Dictionary contain at least name: String and type: int (see Variant.Type) entries. Optionally, it can also include hint: int (see [enum PropertyHint]), hint_string: String, and usage: int (see [enum PropertyUsageFlags]).

    public Reference GetScript()

Returns the object’s Script instance, or null if none is assigned.

    public Godot.Collections.Array GetSignalConnectionList(string signal)

Returns an Array of connections for the given signal.

    public Godot.Collections.Array GetSignalList()

Returns the list of signals as an Array of dictionaries.

    public bool HasMeta(string name)

Returns true if a metadata entry is found with the given name.

    public bool HasMethod(string method)

Returns true if the object contains the given method.

    public bool HasUserSignal(string signal)

Returns true if the given user-defined signal exists.

    public bool IsBlockingSignals()

Returns true if signal emission blocking is enabled.

    public bool IsClass(string @class)

Returns true if the object inherits from the given class.

    public bool IsConnected(string signal, Object target, string method)

Returns true if a connection exists for a given signal, target, and method.

    public bool IsQueuedForDeletion()

Returns true if the Node.QueueFree() method was called for the object.

    public void Notification(int what, bool reversed = false)

Send a given notification to the object, which will also trigger a call to the _Notification(int) method of all classes that the object inherits from.

If reversed is true, _Notification(int) is called first on the object’s own class, and then up to its successive parent classes. If reversed is false, _Notification(int) is called first on the highest ancestor (Object itself), and then down to its successive inheriting classes.

    public void PropertyListChangedNotify()

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.

    public void RemoveMeta(string name)

Removes a given entry from the object’s metadata.

    public void Set(string property, object value)

Assigns a new value to the given property. If the property does not exist, nothing will happen.

    public void SetBlockSignals(bool enable)

If set to true, signal emission is blocked.

    public void SetDeferred(string property, object value)

Assigns a new value to the given property, after the current frame’s physics step. This is equivalent to calling _Set(string, object) via CallDeferred(string, params object[]), i.e. call_deferred("set", property, value).

    public void SetIndexed(NodePath property, object value)

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 (:) to access nested properties. Example:

[codeblock]

set_indexed(“position”, Vector2(42, 0))

set_indexed(“position:y”, -10)

print(position) # (42, -10)

[/codeblock]

    public void SetMessageTranslation(bool enable)

Defines whether the object can translate strings (with calls to Tr(string)). Enabled by default.

    public void SetMeta(string name, object value)

Adds or changes a given entry in the object’s metadata. Metadata are serialized, and can take any Variant value.

    public void SetScript(Reference script)

Assigns a script to the object. Each object can have a single script assigned to it, which are used to extend its functionality.

    public SignalAwaiter ToSignal(Object source, string signal)

    public override string ToString()

Returns a String representing the object. If not overridden, defaults to "[ClassName:RID](../Godot.ClassName:RID/)".

Override the method ToString() to customize the String representation.

    public string Tr(string message)

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 message unchanged. See SetMessageTranslation(bool).

Inner Types

ConnectFlags

Name Value Description
Deferred 1 Connects a signal in deferred mode. This way, signal emissions are stored in a queue, then set on idle time.
Persist 2 Persisting connections are saved when the object is serialized to file.
Oneshot 4 One-shot connections disconnect themselves after emission.
ReferenceCounted 8 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.
Tags: