W3cubDocs

/Godot 3.0

Object

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

Category: Core

Brief Description

Base class for all non built-in types.

Member Functions

void _get ( String property ) virtual
Array _get_property_list ( ) virtual
void _init ( ) virtual
void _notification ( int what ) virtual
bool _set ( String property, Variant value ) virtual
void add_user_signal ( String signal, Array arguments=[ ] )
Variant call ( String method ) vararg
Variant call_deferred ( String method ) vararg
Variant callv ( String method, Array arg_array )
bool can_translate_messages ( ) const
int connect ( String signal, Object target, String method, Array binds=[ ], int flags=0 )
void disconnect ( String signal, Object target, String method )
Variant emit_signal ( String signal ) vararg
void free ( )
Variant get ( String property ) const
String get_class ( ) const
Array get_incoming_connections ( ) const
Variant get_indexed ( NodePath property ) const
int get_instance_id ( ) const
Variant get_meta ( String name ) const
PoolStringArray get_meta_list ( ) const
Array get_method_list ( ) const
Array get_property_list ( ) const
Reference get_script ( ) const
Array get_signal_connection_list ( String signal ) const
Array get_signal_list ( ) 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_class ( String type ) const
bool is_connected ( String signal, Object target, String method ) const
bool is_queued_for_deletion ( ) 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_indexed ( NodePath property, Variant value )
void set_message_translation ( bool enable )
void set_meta ( String name, Variant value )
void set_script ( Reference script )
String tr ( String message ) const

Signals

script_changed ( )

Emitted whenever the script of the Object is 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.

Enums

enum ConnectFlags

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

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

Array _get_property_list ( ) virtual

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

void _init ( ) virtual

The virtual method called upon initialization.

void _notification ( int what ) virtual

Notify the object internally using an ID.

bool _set ( String property, Variant value ) virtual

Sets a property. Returns true if the property exists.

void add_user_signal ( String signal, Array arguments=[ ] )

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

Variant call ( String method ) vararg

Calls the method on the object and returns a result. Pass parameters as a comma separated list.

Variant call_deferred ( String method ) vararg

Calls the method on the object during idle time and returns a result. Pass parameters as a comma separated list.

Variant callv ( String method, Array arg_array )

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

bool can_translate_messages ( ) const

Returns true if the object can translate strings.

int connect ( String signal, Object target, String method, Array binds=[ ], 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 is_connected to check for existing connections.

void disconnect ( String signal, Object target, String method )

Disconnects a signal from a method on the given target.

Variant emit_signal ( String signal ) vararg

Emits the given signal.

void free ( )

Deletes the object from memory.

Variant get ( String property ) const

Returns a Variant for a property.

String get_class ( ) const

Returns the object’s class as a String.

Array get_incoming_connections ( ) const

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.

Variant get_indexed ( NodePath property ) const

int get_instance_id ( ) const

Returns the object’s unique instance ID.

Variant get_meta ( String name ) const

Returns the object’s metadata for the given name.

PoolStringArray get_meta_list ( ) const

Returns the object’s metadata as a PoolStringArray.

Array get_method_list ( ) const

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

Array get_property_list ( ) const

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

Reference get_script ( ) const

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

Array get_signal_connection_list ( String signal ) const

Returns an Array of connections for the given signal.

Array get_signal_list ( ) const

Returns the list of signals as an Array of dictionaries.

bool has_meta ( String name ) const

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

bool has_method ( String method ) const

Returns true if the object contains the given method.

bool has_user_signal ( String signal ) const

Returns true if the given user-defined signal exists.

bool is_blocking_signals ( ) const

Returns true if signal emission blocking is enabled.

bool is_class ( String type ) const

Returns true if the object inherits from the given type.

bool is_connected ( String signal, Object target, String method ) const

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

bool is_queued_for_deletion ( ) const

Returns true if the queue_free method was called for the object.

void notification ( int what, bool reversed=false )

Notify the object of something.

void property_list_changed_notify ( )

void set ( String property, Variant value )

Set property into the object.

void set_block_signals ( bool enable )

If set to true, signal emission is blocked.

void set_indexed ( NodePath property, Variant value )

void set_message_translation ( bool enable )

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

void set_meta ( String name, Variant value )

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

void set_script ( Reference script )

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

String tr ( String message ) const

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

© 2014–2018 Juan Linietsky, Ariel Manzur, Godot Engine contributors
Licensed under the MIT License.
http://docs.godotengine.org/en/3.0/classes/class_object.html