Object

Inherited By: Reference, Physics2DServer, Input, Node, Geometry, ARVRPositionalTracker, TreeItem, PhysicsDirectBodyState, ARVRServer, PhysicsDirectSpaceState, Engine, Physics2DDirectSpaceState, MainLoop, InputMap, UndoRedo, PhysicsServer, ProjectSettings, ResourceSaver, Performance, ResourceLoader, AudioServer, VisualServer, IP, ClassDB, OS, EditorSelection, Physics2DDirectBodyState, TranslationServer, EditorFileSystemDirectory

Category: Core

Brief Description

Base class for all non built-in types.

Member Functions

String XL_MESSAGE ( String message ) const
void _get ( String property ) virtual
Array _get_property_list ( ) virtual
void _init ( ) virtual
void _notification ( int what ) virtual
void _set ( String property, Variant value ) virtual
void add_user_signal ( String signal, Array arguments=Array() )
void call ( String method, Variant arg0=NULL, Variant arg1=NULL, Variant arg2=NULL, Variant arg3=NULL, Variant arg4=NULL, Variant arg5=NULL, Variant arg6=NULL, Variant arg7=NULL, Variant arg8=NULL, Variant arg9=NULL )
void call_deferred ( String method, Variant arg0=NULL, Variant arg1=NULL, Variant arg2=NULL, Variant arg3=NULL, Variant arg4=NULL )
Variant callv ( String method, Array arg_array )
bool can_translate_messages ( ) const
int connect ( String signal, Object target, String method, Array binds=Array(), int flags=0 )
void disconnect ( String signal, Object target, String method )
void emit_signal ( String signal, Variant arg0=NULL, Variant arg1=NULL, Variant arg2=NULL, Variant arg3=NULL, Variant arg4=NULL )
void free ( )
void get ( String property ) const
int get_instance_ID ( ) const
Variant get_meta ( String name ) const
StringArray get_meta_list ( ) const
Array get_method_list ( ) const
Array get_property_list ( ) const
Script get_script ( ) const
Array get_signal_connection_list ( String signal ) const
Array get_signal_list ( ) const
String get_type ( ) const
bool has_meta ( String name ) const
bool has_method ( String method ) const
bool has_user_signal ( String signal ) const
bool is_blocking_signals ( ) const
bool is_connected ( String signal, Object target, String method ) const
bool is_queued_for_deletion ( ) const
bool is_type ( String type ) const
void notification ( int what, bool reversed=false )
void property_list_changed_notify ( )
void set ( String property, Variant value )
void set_block_signals ( bool enable )
void set_message_translation ( bool enable )
void set_meta ( String name, Variant value )
void set_script ( Script script )
String tr ( String message ) const

Signals

  • script_changed ( )

Numeric Constants

  • NOTIFICATION_POSTINITIALIZE = 0 — Called right when the object is initialized. Not available in script.
  • NOTIFICATION_PREDELETE = 1 — Called before the object is about to be deleted.
  • CONNECT_DEFERRED = 1 — Connect a signal in deferred mode. This way, signal emissions are stored in a queue, then set on idle time.
  • CONNECT_PERSIST = 2 — Persisting connections are saved when the object is serialized to file.
  • CONNECT_ONESHOT = 4 — One shot connections disconnect themselves after emission.

Description

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 derivates 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 _get_property_list and handled in _get and _set. However, scripting languages and C++ have simpler means to export them.

Objects also receive notifications (_notification). Notifications are a simple way to notify the object about simple events, so they can all be handled together.

Member Function Description

  • void _get ( String property ) virtual

Return a property, return null if the property does not exist.

  • Array _get_property_list ( ) virtual

Return the property list, array of dictionaries, dictionaries must contain: name:String, type:int (see TYPE_* enum in @Global Scope) and optionally: hint:int (see PROPERTY_HINT_* in @Global Scope), hint_string:String, usage:int (see PROPERTY_USAGE_* in @Global Scope).

  • void _init ( ) virtual
  • void _notification ( int what ) virtual

Notification request, the notification id is received.

Set a property. Return true if the property was found.

  • void add_user_signal ( String signal, Array arguments=null )

Add a user signal (can be added anytime). Arguments are optional, but can be added as an array of dictionaries, each containing “name” and “type” (from @Global Scope TYPE_*).

  • bool can_translate_messages ( ) const

Return true if this object can translate strings.

Connect a signal to a method at a target (member function). Binds are optional and are passed as extra arguments to the call. Flags specify optional deferred or one shot connections, see enum CONNECT_*. A signal can only be connected once to a method, and it will throw an error if already connected. If you want to avoid this, use is_connected to check.

Disconnect a signal from a method.

  • void free ( )

Get a property from the object.

Return the class of the object as a string.

  • Array get_incoming_connections ( ) const

Returns an Array of dictionaries with informations about signals that are connected to this 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.
  • int get_instance_id ( ) const

Return the instance ID. All objects have a unique instance ID.

Return a metadata from the object.

Return the list of metadata in the object.

  • Array get_method_list ( ) const
  • Array get_property_list ( ) const

Return the list of properties as an array of dictionaries, dictionaries contain: name:String, type:int (see TYPE_* enum in @Global Scope) and optionally: hint:int (see PROPERTY_HINT_* in @Global Scope), hint_string:String, usage:int (see PROPERTY_USAGE_* in @Global Scope).

Return the object script (or null if it doesn’t have one).

  • Array get_signal_connection_list ( String signal ) const
  • Array get_signal_list ( ) const

Return the list of signals as an array of dictionaries.

Return true if a metadata is found with the requested name.

  • bool is_blocking_signals ( ) const

Return true if signal emission blocking is enabled.

Check the class of the object against a string (including inheritance).

Return true if a connection exists for a given signal and target/method.

  • bool is_queued_for_deletion ( ) const
  • void notification ( int what, bool reversed=null )

Notify the object of something.

  • void property_list_changed_notify ( )

Set property into the object.

  • void set_block_signals ( bool enable )

If set to true, signal emission is blocked.

  • void set_message_translation ( bool enable )

Define whether this object can translate strings (with calls to tr). Default is true.

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

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

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