struct Godot::Variant

Overview

Represents a dynamically typed Godot Variant value in Crystal with zero-allocation unboxing for primitive and engine math types.

Defined in:

libgodot/variant.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.from_arg(arg : LibBridge::VariantArg) : Variant #

Constructs a Variant directly from a native C-bridge VariantArg.


[View source]
def self.new(raw : VariantValue = nil) #

[View source]
def self.new(val : Int32) #

[View source]
def self.new(val : UInt32) #

[View source]
def self.new(val : UInt64) #

[View source]
def self.new(val : Float32) #

[View source]
def self.new(val : Symbol) #

[View source]

Class Method Detail

def self.default_for(type : T.class) : T forall T #

Returns safe default value for target type T


[View source]

Instance Method Detail

def ==(other : Variant) : Bool #

[View source]
def ==(other : String) : Bool #

[View source]
def ==(other : Number) : Bool #

[View source]
def ==(other : Bool) : Bool #

[View source]
def ==(other : Godot::Object) : Bool #

[View source]
def as_aabb : AABB #

[View source]
def as_basis : Basis #

[View source]
def as_bool : Bool #

[View source]
def as_color : Color #

[View source]
def as_f : Float32 #

[View source]
def as_f32 : Float32 #

[View source]
def as_f64 : Float64 #

[View source]
def as_i : Int32 #

[View source]
def as_i32 : Int32 #

[View source]
def as_i64 : Int64 #

[View source]
def as_node : Godot::Node | Nil #

[View source]
def as_obj : Godot::Object | Nil #

[View source]
def as_plane : Plane #

[View source]
def as_quat : Quaternion #

[View source]
def as_rect2 : Rect2 #

[View source]
def as_rect2i : Rect2i #

[View source]
def as_s : String #

[View source]
def as_str : String #

[View source]
def as_t(type : T.class) : T forall T #

Unboxes the Variant to target type T at compile time.


[View source]
def as_transform2d : Transform2D #

[View source]
def as_transform3d : Transform3D #

[View source]
def as_u32 : UInt32 #

[View source]
def as_u64 : UInt64 #

[View source]
def as_v2 : Vector2 #

[View source]
def as_v2i : Vector2i #

[View source]
def as_v3 : Vector3 #

[View source]
def as_v3i : Vector3i #

[View source]
def as_v4 : Vector4 #

[View source]
def as_v4i : Vector4i #

[View source]
def bool? : Bool #

[View source]
def empty? : Bool #

[View source]
def float? : Bool #

[View source]
def int? : Bool #

[View source]
def is_nil? : Bool #

[View source]
def object? : Bool #

[View source]
def raw : VariantValue #

[View source]
def string? : Bool #

[View source]
def to_s(io : IO) : Void #
Description copied from struct Struct

Same as #inspect(io).


[View source]