0.1.0 • Published 10 months ago

@galacean/editor-decorators v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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", {
    min: 1,
    max: 10,
  })
  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

type ComponentType =
  | "Input"
  | "Number"
  | "Slider"
  | "Boolean"
  | "Vector2"
  | "Vector3"
  | "Vector4"
  | "Rect"
  | "Color"
  | "AssetPicker"
  | "Select"
  | "SegmentControl"
  | "Textarea"

Common options

NameTypeRequiredDescriptionDefault
propertystring-The name according with EngineObjectThe name of the decorated property
labelstring-Label for the value, would be shown in the Inspector
infostring-Additional information or a description about the GUI item.
prioritynumber-The priority of the GUI item. The higher the priority, the higher the item is displayed in the Inspector.

NumberOptions

NameTypeRequiredDescriptionDefault
maxnumber-Maximum value
minnumber-Minimum value
dragStepnumber-Step value when dragging

SliderOptions

NameTypeRequiredDescriptionDefault
maxnumber-Maximum value
minnumber-Minimum value
dragStepnumber-Step value when dragging

AssetPickerOptions

NameTypeRequiredDescriptionDefault
assetTypeAssetTypeThe type of the asset
type AssetType =
  | "Scene"
  | "AnimationClip"
  | "Folder"
  | "AmbientLight"
  | "glTF"
  | "Texture2D"
  | "HDR"
  | "AnimatorController"
  | "Lottie"
  | "Spine"
  | "sprite"
  | "Font"
  | "script"
  | "Material"
  | "Mesh"
  | "Audio"

SelectOptions

NameTypeRequiredDescriptionDefault
options{ value: string, label: string }[]The options of the select
0.1.0

10 months ago

0.0.9

11 months ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.4-beta.11

2 years ago

0.0.4

2 years ago

0.0.4-beta.10

2 years ago

0.0.4-beta.9

2 years ago

0.0.4-beta.8

3 years ago

0.0.4-beta.7

3 years ago

0.0.4-beta.6

3 years ago

0.0.4-beta.5

3 years ago

0.0.4-beta.4

3 years ago

0.0.4-beta.3

3 years ago

0.0.4-beta.2

3 years ago

0.0.4-beta.1

3 years ago

0.0.4-beta.0

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago