Object

    Base class for all other classes in the engine.

    Object.swift:38
    class Object

    An advanced Variant type. All classes in the engine inherit from Object. Each class may define new properties, methods or signals, which are available to all inheriting classes. For example, a Sprite2D instance is able to call Node/addChild(node:forceReadableName:`internal`:) because it inherits from Node.

    You can create new instances, using Object.new() in GDScript, or new GodotObject in C#.

    To delete an Object instance, call free(). This is necessary for most classes inheriting Object, because they do not manage memory on their own, and will otherwise cause memory leaks when no longer in use. There are a few classes that perform memory management. For example, RefCounted (and by extension Resource) deletes itself when no longer referenced, and Node deletes its children when freed.

    Objects can have a Script attached to them. Once the Script is instantiated, it effectively acts as an extension to the base class, allowing it to define and inherit new properties, methods and signals.

    Inside a Script, _getPropertyList() may be overridden to customize properties in several ways. This allows them to be available to the editor, display as lists of options, sub-divide into groups, save on disk, etc. Scripting languages offer easier ways to customize properties, such as with the [annotation @GDScript.@export] annotation.

    Godot is very dynamic. An object’s script, and therefore its properties, methods and signals, can be changed at run-time. Because of this, there can be occasions where, for example, a property required by a method may not exist. To prevent run-time errors, see methods such as set(property:value:), get(property:), call(method:), hasMethod(_:), hasSignal(_:), etc. Note that these methods are much slower than direct references.

    In GDScript, you can also check if a given property, method, or signal name exists in an object with the in operator:

    Notifications are integer constants commonly sent and received by objects. For example, on every rendered frame, the SceneTree notifies nodes inside the tree with a NodenotificationProcess````. The nodes receive it and may call _process(delta:) to update. To make use of notifications, see ``notification(what:reversed:)`` and ``_notification()``.

    Lastly, every object can also contain metadata (data about data). setMeta(name:value:) can be useful to store information that the object itself does not depend on. To keep your code clean, making excessive use of metadata is discouraged.

    This object emits the following signals:

    Superclasses

    • class Wrapped

      The base class for all class bindings in Godot, you should not have to instantiate or subclass this class directly - there are better options in the hierarchy.

    Citizens in SwiftGodot

    Conformances

    • protocol CustomStringConvertible

      A type with a customized textual representation.

    • protocol Equatable

      A type that can be compared for value equality.

    • protocol Hashable

      A type that can be hashed into a Hasher to produce an integer hash value.

    • protocol Identifiable<ID>

      A class of types whose instances hold the value of an entity with stable identity.

    • protocol VariantRepresentable

      Types that conform to VariantRepresentable can be stored directly in Variant with no conversion. These include all of the Variant types from Godot (for example GString, Rect, Plane), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.

    • protocol VariantStorable

      Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.

    Types

    Typealiases

    Type members

    Instance members

    Type features

    Instance features

    Subclasses