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

Base class for all non built-in types. Everything not a built-in type starts the inheritance chain from this class.

Objects do not manage memory, if inheriting from one the object will most likely have to be deleted manually (call the Free() function from the script or delete from C++).

Some derivatives add memory management, such as Reference (which keeps a reference count and deletes itself automatically when no longer referenced) and Node, which deletes the children tree when deleted.

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 (_Notification(int)). Notifications are a simple way to notify the object about simple events, so they can all be handled together.

Inheritance Chain

Derived Classes

Static Fields

    public const Int32 NotificationPostinitialize = 0

    public const Int32 NotificationPredelete = 1

Constructors

    public Object()

Signals

    "script_changed" ()

Emitted whenever the script of the Object is changed.

Properties

    public IntPtr NativeInstance { get; }

Methods

    public virtual void _Get(string property)

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

    public virtual Array _GetPropertyList()

Returns the object’s property list as an Array of dictionaries. Dictionaries must contain: name:String, type:int (see TYPE_* enum in [@GlobalScope]) and optionally: hint:int (see PROPERTY_HINT_* in [@GlobalScope]), hint_string:String, usage:int (see PROPERTY_USAGE_* in [@GlobalScope]).

    public virtual void _Init()

The virtual method called upon initialization.

    public virtual void _Notification(int what)

Notify the object internally using an ID.

    public virtual bool _Set(string property, object value)

Sets a property. Returns true if the property exists.

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

Adds a user-defined signal. Arguments are optional, but can be added as an Array of dictionaries, each containing “name” and “type” (from [@GlobalScope] TYPE_*).

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

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

    public object Callv(string method, Array argArray)

Calls the method on the object and returns a result. Pass parameters as an Array.

    public bool CanTranslateMessages()

Returns true if the object can translate strings.

    public Error Connect(string signal, Object target, string method, Array binds = null, int flags = 0)

Connects a signal to a method on a target object. Pass optional binds to the call. Use flags to set deferred or one shot connections. See CONNECT_* constants. A signal can only be connected once to a method. It will throw an error if already connected. To avoid this, first use IsConnected(string, Godot.Object, string) to check for existing connections.

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

Disconnects a signal from a method on the given target.

    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.

    public object Get(string property)

Returns a Variant for a property.

    public string GetClass()

Returns the object’s class as a String.

    public Array GetIncomingConnections()

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

Inside each Dictionary there are 3 fields:

  • “source” is a reference to signal emitter.

  • “signal_name” is name of connected signal.

  • “method_name” is a name of method to which signal is connected.

    public object GetIndexed(NodePath property)

    public int GetInstanceId()

Returns the object’s unique instance ID.

    public object GetMeta(string name)

Returns the object’s metadata for the given name.

    public string[] GetMetaList()

Returns the object’s metadata as a PoolStringArray.

    public Array GetMethodList()

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

    public Array GetPropertyList()

Returns the list of properties as an Array of dictionaries. Dictionaries contain: name:String, type:int (see TYPE_* enum in [@GlobalScope]) and optionally: hint:int (see PROPERTY_HINT_* in [@GlobalScope]), hint_string:String, usage:int (see PROPERTY_USAGE_* in [@GlobalScope]).

    public Reference GetScript()

Returns the object’s Script or null if one doesn’t exist.

    public Array GetSignalConnectionList(string signal)

Returns an Array of connections for the given signal.

    public Array GetSignalList()

Returns the list of signals as an Array of dictionaries.

    public bool HasMeta(string name)

Returns true if a metadata 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 type)

Returns true if the object inherits from the given type.

    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 queue_free method was called for the object.

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

Notify the object of something.

    public void PropertyListChangedNotify()

    public void Set(string property, object value)

Set property into the object.

    public void SetBlockSignals(bool enable)

If set to true, signal emission is blocked.

    public void SetIndexed(NodePath property, object value)

    public void SetMessageTranslation(bool enable)

Define whether the object can translate strings (with calls to Tr(string)). Default is true.

    public void SetMeta(string name, object value)

Set a metadata into the object. Metadata is serialized. Metadata can be anything.

    public void SetScript(Reference script)

Set a script into the object, scripts extend the object functionality.

    public SignalAwaiter ToSignal(Object source, string signal)

    public string Tr(string message)

Translate a message. Only works if message translation is enabled (which it is by default). See SetMessageTranslation(bool).

Inner Types

ConnectFlags

Name Value Description
Deferred 1 Connect 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.
Tags: