Breakroom is now Sinewave Campus. Book a meeting

SStateMachine

客户端组件
在此类中NextState
  1. 函数
  2. NextState
  3. PrevState
  4. SetState
  5. BindToUI
  6. 属性
  7. Enabled
  8. StateCount
  9. StateNames
  10. CurrentState
  11. CurrentStateName
  12. ComponentName
  13. GameObject
成员 11
函数NextStateEnter the next state
函数PrevState–
函数SetStateEnters the state of being set that its order is "state"
函数BindToUIThe state machine will bind itself to all Toggles, Buttons, Dropdowns and Sliders on the SGameObject it is in or on a specified SGameObject.
属性EnabledWhether the simple state machine component is Enabled or not
属性StateCountTotal number of States.
属性StateNamesA list of the names of all States.
属性CurrentStateThe index number of the current state.
属性CurrentStateNameThe name of the current state, or null if no state.
属性ComponentNameThe name of this component.
属性GameObjectThe GameObject this component is attached to.

函数​

NextState​

void NextState()

Enter the next state

返回值

void

示例

Lua
Space.Host.ExecutingObject.StateMachine.NextState()

PrevState​

void PrevState()

返回值

void

示例

Lua
Space.Host.ExecutingObject.StateMachine.PrevState()

SetState​

void SetState(int state)
void SetState(string state)

Enters the state of being set that its order is "state"

参数

参数类型说明
stateintThe index of the state. First state is 1.
statestringThe name of the state as set in the State Machine component.

返回值

void

示例

Lua
Space.Host.ExecutingObject.StateMachine.SetState(2)
--or
Space.Host.ExecutingObject.StateMachine.SetState('A State Name')

BindToUI​

void BindToUI()
void BindToUI(SGameObject go)

The state machine will bind itself to all Toggles, Buttons, Dropdowns and Sliders on the SGameObject it is in or on a specified SGameObject.

Binding to Button : Clicking button will call NextState()
Binding to Toggle: Toggle On sets State to 1, Toggle Off sets state to 2
Binding to Dropdown: Selecting will set State to that selection's caption text
Binding to Slider: Moving slider changes State to slider value

参数

参数类型说明
goSGameObjectA specific SGameObject which this State Machine will bind to.

返回值

void

示例

Lua
Space.Host.ExecutingObject.StateMachine.BindToUI()
----or
Space.Host.ExecutingObject.StateMachine.BindToUI(Space.Host.GetReference("a reference"))

属性​

Enabled​

bool Enabled {get; set; }

Whether the simple state machine component is Enabled or not

示例

Lua
Space.Host.ExecutingObject.StateMachine.Enabled = false

StateCount只读​

int StateCount {get; }

Total number of States.

示例

Lua
numberOfStates = Space.Host.ExecutingObject.StateMachine.StateCount

StateNames只读​

string[] StateNames {get; }

A list of the names of all States.

示例

Lua
tableStateNames = Space.Host.ExecutingObject.StateMachine.StateNames

CurrentState只读​

int CurrentState {get; }

The index number of the current state.

示例

Lua
currentState = Space.Host.ExecutingObject.StateMachine.CurrentState

CurrentStateName只读​

string CurrentStateName {get; }

The name of the current state, or null if no state.

示例

Lua
currentStateName = Space.Host.ExecutingObject.StateMachine.CurrentStateName

ComponentName只读​

string ComponentName {get; }

The name of this component.

示例

Lua
componentName = Space.Host.ExecutingObject.StateMachine.ComponentName

GameObject只读​

SGameObject GameObject {get; }

The GameObject this component is attached to. A component is always attached to a GameObject.

示例

Lua
theGameObject = Space.Host.ExecutingObject.StateMachine.GameObject