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

Instance methods inherited from class Object

try?(&)
try?
try?

Constructor Detail

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

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


def self.new(raw : VariantValue = nil) #

def self.new(val : Variant) : Variant #

def self.new(val : Int32) #

def self.new(val : UInt32) #

def self.new(val : UInt64) #

def self.new(val : Float32) #

def self.new(val : Symbol) #

def self.new(val : Enum) #

Class Method Detail

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

Returns safe default value for target type T


def self.from_any?(val) : Variant | Nil #

def self.value_to_arg(val) : LibBridge::VariantArg #

Instance Method Detail

def ==(other : Variant) : Bool #

def ==(other : String) : Bool #

def ==(other : Number) : Bool #

def ==(other : Bool) : Bool #

def ==(other : Godot::Object) : Bool #

def as_aabb : AABB #

def as_basis : Basis #

def as_bool(default : Bool = false) : Bool #

def as_bool? : Bool | Nil #

def as_color(default : Color = Color.new) : Color #

def as_color_coerce(default : Color = Color.new) : Color #

def as_dict : Godot::Dictionary #

def as_dictionary : Godot::Dictionary #

def as_f(default : Float32 = 0.0_f32) : Float32 #

def as_f32(default : Float32 = 0.0_f32) : Float32 #

def as_f64(default : Float64 = 0.0) : Float64 #

def as_i(default : Int32 = 0) : Int32 #

def as_i32(default : Int32 = 0) : Int32 #

def as_i64(default : Int64 = 0_i64) : Int64 #

def as_node : Godot::Node | Nil #

def as_obj : Godot::Object | Nil #

def as_plane : Plane #

def as_quat : Quaternion #

def as_rect2 : Rect2 #

def as_rect2i : Rect2i #

def as_s(default : String = "") : String #

def as_s? : String | Nil #

def as_str(default : String = "") : String #

def as_t(type : T.class) : T forall T #

Unboxes the Variant to target type T at compile time.


def as_transform2d : Transform2D #

def as_transform3d : Transform3D #

def as_u32(default : UInt32 = 0_u32) : UInt32 #

def as_u64(default : UInt64 = 0_u64) : UInt64 #

def as_v2(default : Vector2 = Vector2.new) : Vector2 #

def as_v2_coerce(default : Vector2 = Vector2.new) : Vector2 #

def as_v2i : Vector2i #

def as_v3(default : Vector3 = Vector3.new) : Vector3 #

def as_v3_coerce(default : Vector3 = Vector3.new) : Vector3 #

def as_v3i : Vector3i #

def as_v4 : Vector4 #

def as_v4i : Vector4i #

def as_vector2(default : Vector2 = Vector2.new) : Vector2 #

def as_vector2i : Vector2i #

def as_vector3(default : Vector3 = Vector3.new) : Vector3 #

def as_vector3i : Vector3i #

def bool? : Bool #

def empty? : Bool #

def float? : Bool #

def int? : Bool #

def is_nil? : Bool #

def object? : Bool #

def raw : VariantValue #

def string? : Bool #

def to_arg : LibBridge::VariantArg #

def to_s(io : IO) : Void #
Description copied from struct Struct

Same as #inspect(io).