ClassInfo
Provides support to expose Swift methods and signals to the Godot runtime, making it callable from its runtime and scripting language.
ClassServices.swift:31class ClassInfo<T> where T : Object
You create a ClassInfo object, with the name for your class, and then call the various register methods. You only need to do once per class, so it is recommended that you perform this initialization with an idiom like this:
class MyNode: Node {
func initClass() -> Bool {
let classInfo = ClassInfo<SpinningCube>(name: "MyNode")
// register things in classInfo here:
...
return true
}
required init () {
super.init ()
let _ = initClass ()
}
Citizens in SwiftGodot
Type members
init(name: StringName
) Initializes a ClassInfo structure to register operations with Godot
Instance members
func addPropertyGroup(name: String, prefix: String
) Starts a new property group for this class, all the properties declared after calling this method will be shown together in the UI under this group.
func addPropertySubgroup(name: String, prefix: String
) Starts a new property sub-group, all the properties declared after calling this method will be shown together in the UI under this group.
func registerMethod(name: StringName, flags: MethodFlags, returnValue: PropInfo?, arguments: [PropInfo], function: @escaping (T) -> ([Variant]) -> Variant?
) Exposes a new method to the Godot world with the specific name
func registerProperty(PropInfo, getter: StringName, setter: StringName
) Registers the property in the class with the information provided in
info
. Thegetter
andsetter
name corresponds to the names that were used to register the function with Godot inregisterMethod
func registerSignal(name: StringName, arguments: [PropInfo]
) Registers a signal on this type with the specified name and with the specified arguments. To trigger the signal, you need to invoke
Object/emitSignal(signal:_:)
with the matching arguments that you registered here.
Citizens in SwiftGodot
where T:Object
Typealiases
typealias ClassInfoFunction
A type alias referencing a class info function that can be registered.
typealias RegisteredIntEnum
A type alias referencing a registerable int enum.
Type members
static func withCheckedProperty(named: String, in: [Variant], perform: (Variant) -> Void
) -> Variant? Performs an operation on an argument that originates from a setter method.
Instance members
func registerCheckbox(named: String, prefix: String?, getter: @escaping ClassInfoFunction, setter: @escaping ClassInfoFunction
) Registers a checkbox toggle in the editor.
func registerEnum<Enum>(named: String, for: Enum.Type, prefix: String?, getter: @escaping ClassInfoFunction, setter: @escaping ClassInfoFunction
) Registers an enumeration in the editor.
func registerFilePicker(named: String, allowedTypes: [String], prefix: String?, getter: @escaping ClassInfoFunction, setter: @escaping ClassInfoFunction
) Registers a file picker in the editor.
func registerInt(named: String, range: ClosedRange<Int>, stride: Int, prefix: String?, getter: @escaping ClassInfoFunction, setter: @escaping ClassInfoFunction
) Registers a number field in the number that can be adjusted in a range.
func registerNodePath(named: String, prefix: String?, getter: @escaping ClassInfoFunction, setter: @escaping ClassInfoFunction
) Registers a node path picker in the editor.
func registerTextField(named: String, prefix: String?, getter: @escaping ClassInfoFunction, setter: @escaping ClassInfoFunction
) Registers a text field.
func registerTextView(named: String, prefix: String?, getter: @escaping ClassInfoFunction, setter: @escaping ClassInfoFunction
) Registers a multiline text view in the editor.