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 : Variant) : Variant
- .new(val : Int32)
- .new(val : UInt32)
- .new(val : UInt64)
- .new(val : Float32)
- .new(val : Symbol)
- .new(val : Enum)
Class Method Summary
-
.default_for(type : T.class) : T forall T
Returns safe default value for target type T
- .from_any?(val) : Variant | Nil
- .value_to_arg(val) : LibBridge::VariantArg
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(default : Bool = false) : Bool
- #as_bool? : Bool | Nil
- #as_color(default : Color = Color.new) : Color
- #as_color_coerce(default : Color = Color.new) : Color
- #as_dict : Godot::Dictionary
- #as_dictionary : Godot::Dictionary
- #as_f(default : Float32 = 0.0_f32) : Float32
- #as_f32(default : Float32 = 0.0_f32) : Float32
- #as_f64(default : Float64 = 0.0) : Float64
- #as_i(default : Int32 = 0) : Int32
- #as_i32(default : Int32 = 0) : Int32
- #as_i64(default : Int64 = 0_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(default : String = "") : String
- #as_s? : String | Nil
- #as_str(default : String = "") : 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(default : UInt32 = 0_u32) : UInt32
- #as_u64(default : UInt64 = 0_u64) : UInt64
- #as_v2(default : Vector2 = Vector2.new) : Vector2
- #as_v2_coerce(default : Vector2 = Vector2.new) : Vector2
- #as_v2i : Vector2i
- #as_v3(default : Vector3 = Vector3.new) : Vector3
- #as_v3_coerce(default : Vector3 = Vector3.new) : Vector3
- #as_v3i : Vector3i
- #as_v4 : Vector4
- #as_v4i : Vector4i
- #as_vector2(default : Vector2 = Vector2.new) : Vector2
- #as_vector2i : Vector2i
- #as_vector3(default : Vector3 = Vector3.new) : Vector3
- #as_vector3i : Vector3i
- #bool? : Bool
- #empty? : Bool
- #float? : Bool
- #int? : Bool
- #is_nil? : Bool
- #object? : Bool
- #raw : VariantValue
- #string? : Bool
- #to_arg : LibBridge::VariantArg
-
#to_s(io : IO) : Void
Same as
#inspect(io).
Instance methods inherited from class Object
try?(&)try? try?
Constructor Detail
Constructs a Variant directly from a native C-bridge VariantArg.