Object

Inherited By: Reference, Physics2DServer, Input, SpatialSound2DServer, Node, Geometry, TreeItem, PhysicsDirectSpaceState, Physics2DDirectSpaceState, MainLoop, InputMap, UndoRedo, PhysicsServer, ResourceSaver, Performance, PathRemap, ResourceLoader, AudioServer, SpatialSoundServer, VisualServer, IP, OS, Globals, PhysicsDirectBodyState, EditorSelection, Physics2DDirectBodyState, TranslationServer

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

Deprecated, will go away.

  • 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 globals) and optionally: hint:int (see PROPERTY_HINT_* in globals), hint_string:String, usage:int (see PROPERTY_USAGE_* in globals).

  • 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=Array() )

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_*).

Call a function in the object, result is returned.

Create and store a function in the object. The call will take place on idle time.

  • 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.

Emit a signal. Arguments are passed in an array.

  • void free ( )
  • void get ( String property ) const

Get a property from the object.

  • 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 globals) and optionally: hint:int (see PROPERTY_HINT_* in globals), hint_string:String, usage:int (see PROPERTY_USAGE_* in globals).

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 the type of the object as a string.

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

  • bool is_blocking_signals ( ) const

Return true if signal emission blocking is enabled.

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

  • bool is_queued_for_deletion ( ) const

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

  • void notification ( int what, bool reversed=false )

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 )

Set true if this object can translate strings (in calls to tr() ). Default is true.

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

  • void set_script ( Script script )

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

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