Variant

    Variant objects box various Godot Objects, you create them with one of the constructors, and you can retrieve the contents using the various extension constructors that are declared on the various types that are wrapped.

    Variant.swift:45
    class Variant

    You can retrieve the type of a variant from the gtype property.

    A Variant takes up only 20 bytes and can store almost any engine datatype inside of it. Variants are rarely used to hold information for long periods of time. Instead, they are used mainly for communication, editing, serialization and moving data around.

    A Variant:

    • Can store almost any Godot engine datatype.

    • Can perform operations between many variants. GDScript uses Variant as its atomic/native datatype.

    • Can be hashed, so it can be compared to other variants.

    • Can be used to convert safely between datatypes.

    • Can be used to abstract calling methods and their arguments. Godot exports all its functions through variants.

    • Can be used to defer calls or move data between threads.

    • Can be serialized as binary and stored to disk, or transferred via network.

    • Can be serialized to text and use it for printing values and editable settings.

    • Can work as an exported property, so the editor can edit it universally.

    • Can be used for dictionaries, arrays, parsers, etc.

    Modifications to a container will modify all references to it.

    Citizens in SwiftGodot

    Conformances

    Types

    Type members

    Instance members

    Type features