See Docs: Using Custom Types
Overview
Creating a subclass of a Godot type involves a few steps:
- Subclassing an existing Godot type with the usual Swift syntax.
- Registering your type with Godot, so users can create instances of it and configure it from the user interface.
- Augment the type with your own custom behaviors.
- Expose your properties, methods and signals to the Godot Editor.
- Setting up your SwiftGodot GDExtension by defining it in The .gdextension file
Type Levels
A custom swift type can be registered at different levels. See docs for GDExtension.InitializationLevel using the macro initSwiftExtension(cdecl:coreTypes:editorTypes:sceneTypes:serverTypes:)
(see docs).
When Godot initializes your extension it does so in stages and you get a chance to register the types that you want to expose to the Godot engine for each stage (GDExtension.InitializationLevel
).
For example, to initialize a Swift extension to Godot with some custom types to use in the editor, and some other types to use on the scene.