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.


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

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) #

Class Method Detail

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

Returns safe default value for target type T


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 : Bool #

def as_color : Color #

def as_f : Float32 #

def as_f32 : Float32 #

def as_f64 : Float64 #

def as_i : Int32 #

def as_i32 : Int32 #

def as_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 : String #

def as_str : 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 : UInt32 #

def as_u64 : UInt64 #

def as_v2 : Vector2 #

def as_v2i : Vector2i #

def as_v3 : Vector3 #

def as_v3i : Vector3i #

def as_v4 : Vector4 #

def as_v4i : Vector4i #

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_s(io : IO) : Void #
Description copied from struct Struct

Same as #inspect(io).