VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
VariantStorable.swift:19protocol VariantStorable
As a convenience, SwiftGodot provides conformances for some native Swift types like String, Bool, Int, Float below, but you can also add your own conformances.
Every VariantStorable must be able to convert to an underlying VariantRepresentable
type which is one that can be stored natively in a Variant
.
Requirements
Type members
associatedtype Representable
init?(Variant
) Creates an instance using a variant
Instance members
Citizens in SwiftGodot
Type members
static func makeOrUnwrap(Variant
) -> Self? Unwraps an object from a variant.
static func makeOrUnwrap(Variant
) -> Self? Unwraps an object from a variant. This is useful when you want one method to call that will return the unwrapped Variant, regardless of whether it is a SwiftGodot.Object or not.
Subtypes
protocol ContentVariantRepresentable
Some of Godot’s builtin classes use ContentType for storage. This needs to be public because it affects their initialization, but SwiftGodot users should never need to conform their types to
ContentVariantRepresentable
.protocol SelfVariantRepresentable
Structs and scalar types use their own layout for storage.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.