struct
Godot::Variant
- Godot::Variant
- Struct
- Value
- Object
Overview
Represents a dynamically typed Godot Variant value in Crystal with zero-allocation unboxing for primitive and engine math types.
Defined in:
libgodot/variant.crConstructors
-
.from_arg(arg : LibBridge::VariantArg) : Variant
Constructs a Variant directly from a native C-bridge VariantArg.
- .new(raw : VariantValue = nil)
- .new(val : Int32)
- .new(val : UInt32)
- .new(val : UInt64)
- .new(val : Float32)
- .new(val : Symbol)
Class Method Summary
-
.default_for(type : T.class) : T forall T
Returns safe default value for target type T
Instance Method Summary
- #==(other : Variant) : Bool
- #==(other : String) : Bool
- #==(other : Number) : Bool
- #==(other : Bool) : Bool
- #==(other : Godot::Object) : Bool
- #as_aabb : AABB
- #as_basis : Basis
- #as_bool : Bool
- #as_color : Color
- #as_f : Float32
- #as_f32 : Float32
- #as_f64 : Float64
- #as_i : Int32
- #as_i32 : Int32
- #as_i64 : Int64
- #as_node : Godot::Node | Nil
- #as_obj : Godot::Object | Nil
- #as_plane : Plane
- #as_quat : Quaternion
- #as_rect2 : Rect2
- #as_rect2i : Rect2i
- #as_s : String
- #as_str : String
-
#as_t(type : T.class) : T forall T
Unboxes the Variant to target type T at compile time.
- #as_transform2d : Transform2D
- #as_transform3d : Transform3D
- #as_u32 : UInt32
- #as_u64 : UInt64
- #as_v2 : Vector2
- #as_v2i : Vector2i
- #as_v3 : Vector3
- #as_v3i : Vector3i
- #as_v4 : Vector4
- #as_v4i : Vector4i
- #bool? : Bool
- #empty? : Bool
- #float? : Bool
- #int? : Bool
- #is_nil? : Bool
- #object? : Bool
- #raw : VariantValue
- #string? : Bool
-
#to_s(io : IO) : Void
Same as
#inspect(io).
Constructor Detail
Constructs a Variant directly from a native C-bridge VariantArg.
Class Method Detail
Returns safe default value for target type T
Instance Method Detail
Unboxes the Variant to target type T at compile time.