Airship Scriptable Objects
AirshipScriptableObject is in beta pending full release, and may not work on some platforms yet
Windows and MacOS
Android and iOS
Using this feature on currently unsupported platforms may not work as expected.
AirshipScriptableObject is a class you can derive from to create objects that live independently of GameObjects. This allows you to save data as an asset to use at runtime.
Like ScriptableObject in Unity, they are accessible from scenes and assets within a project.
// This will show in Create -> ScriptableObjects -> Example Data Object by default
@CreateAssetMenu()
export default class ExampleDataObject extends AirshipScriptableObject {
public message = "Hello, world!";
protected Awake() {
// This will be fired when the scriptable object is first referenced/created.
// The properties of this object will be set up on Awake
print(this.message, "from the example scriptable object awake!");
}
protected OnDestroy() {
// This will be called if:
// - A CreateInstance() ScriptableObject is destroyed
print("This object was destroyed!");
}
}This allows you to save data as an asset to use at runtime. This can be useful for global data shared between objects, avoiding the necessity for duplicate data.
Referencing a ScriptableObject in your game
As an example, we can use a ScriptableObject to create "templates" for NPCs we want to spawn
Then we can create it using the menu item:

CreateAssetMenu on it, it will show up here by default.
Then to reference the ScriptableObject

Then click on the None (NPC Template) button - and it will give you a prompt to select a scriptable object of that type, which we can then select -

Then when you run the game - it spawns the NPC with the name and health!


Last updated