0.0.4 • Published 3 months ago
@galacean/editor-decorators v0.0.4
editor-decorators
A collection of decorator functions helps you write scripts in Galacean Editor.
Installation
npm install @galacean/editor-decorators
Usage
import { Script } from '@galacean/engine';
import { inspect } from "@galacean/editor-decorators";
export default class extends Script {
@inspect('Number', {
value: 1,
})
rotate = 1;
onUpdate(deltaTime: number) {
this.entity.transform.rotate(this.rotate, this.rotate, this.rotate);
}
}
API
inspect(type: ComponentType, options: ComponentOptions)
This decorator exports the property to the Editor. It can be used on any property of a class. The property will be shown in the Inspector of the Editor.
ComponenType
export type ComponentType = "Input" | "Number" | "Slider" | "Boolean" | "Vector2" | "Vector3" | "Vector4" | "Rect" | "Color" | "AssetPicker" | "Select" | "SegmentControl" | "Textarea";
Common options
Name | Type | Required | Description | Default |
---|---|---|---|---|
value | any | ✓ | Default value | undefined |
property | string | - | The name according with EngineObject | The name of the decorated property |
label | string | - | Label for the value, would be shown in the Inspector | |
info | string | - | Additional information or a description about the GUI item. | |
priority | number | - | The priority of the GUI item. The higher the priority, the higher the item is displayed in the Inspector. | |
onChange | (instance: any, property: string, value: unknown) => void | - | Callback when the value is changed |
NumberOptions
Name | Type | Required | Description | Default |
---|---|---|---|---|
max | number | - | Maximum value | |
min | number | - | Minimum value | |
dragStep | number | - | Step value when dragging |
AssetPickerOptions
Name | Type | Required | Description | Default |
---|---|---|---|---|
assetType | string | - | The type of the asset | |
customFilter | (asset: any) => boolean; | - | The filter of the asset |
SelectOptions
Name | Type | Required | Description | Default |
---|---|---|---|---|
options | string[] | - | The options of the select |
0.0.4-beta.11
3 months ago
0.0.4
3 months ago
0.0.4-beta.10
4 months ago
0.0.4-beta.9
4 months ago
0.0.4-beta.8
8 months ago
0.0.4-beta.7
10 months ago
0.0.4-beta.6
11 months ago
0.0.4-beta.5
11 months ago
0.0.4-beta.4
11 months ago
0.0.4-beta.3
11 months ago
0.0.4-beta.2
11 months ago
0.0.4-beta.1
11 months ago
0.0.4-beta.0
11 months ago
0.0.3
11 months ago
0.0.2
11 months ago