Editor.Assets.ScriptType
EnumThe kind of script a Editor.Assets.ScriptAsset defines: a component that can be attached to a scene object, a module that other scripts import, or a custom a…
The kind of script a Editor.Assets.ScriptAsset defines: a component that can be attached to a scene object, a module that other scripts import, or a custom asset type.
Index
Example
// Attach a script to a scene object only when it is a component script.
// Module and custom asset scripts are skipped.
export function attachComponentScript(
sceneObject: Editor.Model.SceneObject,
script: Editor.Assets.ScriptAsset,
): Editor.Components.ScriptComponent | null {
if (script.scriptType !== Editor.Assets.ScriptType.Component) {
console.log(`${script.name} is not a component script; skipping`);
return null;
}
const component = sceneObject.addComponent('ScriptComponent');
component.scriptAsset = script;
return component;
}
Enumeration Members
Asset
Asset:
number
A custom asset script, such as a TypeScript class that extends BaseCustomAsset or uses @asset, or a JavaScript file that starts with // @asset.
Component
Component:
number
A script component, such as a TypeScript class that extends BaseScriptComponent or uses @component. It can be attached to a scene object through a Editor.Components.ScriptComponent.
Module
Module:
number
A script module that other scripts import, such as a TypeScript file without a component or asset declaration, or a JavaScript file that uses module.exports or starts with // @module.