Breakroom is now Sinewave Campus. Book a meeting

SAnimation

客户端组件
在此类中GetState
  1. 函数
  2. GetState
  3. Blend
  4. CrossFade
  5. CrossFadeQueued
  6. GetClipCount
  7. IsPlaying
  8. Play
  9. PlayQueued
  10. Rewind
  11. Sample
  12. Stop
  13. 属性
  14. Enabled
  15. States
  16. GameObject
成员 14
函数GetStateReturns the SAnimationState for the default animation clip.
函数BlendBlends the animation named animation towards targetWeight over the next time seconds.
函数CrossFadeFades the animation with name animation in over a period of time seconds and fades other animations out.
函数CrossFadeQueuedReturns a duplicated SAnimationState.
函数GetClipCountGet the number of clips currently assigned to this animation.
函数IsPlayingIs the animation named name playing?
函数PlayPlays an animation without any blending.
函数PlayQueuedReturns a duplicated SAnimationState.
函数RewindRewinds the animation named name.
函数SampleSamples animations at the current state.
函数StopStops all playing animations that were started with this Animation.
属性EnabledWhether this component is enabled or not.
属性StatesReturns a table of SAnimationState names and references
属性GameObjectReturns a reference to the GameObject of this component.

函数​

GetState​

SAnimationState GetState()
SAnimationState GetState(string state)

Returns the SAnimationState for the default animation clip.

参数

名称类型默认值
statestring–

返回值

SAnimationState

示例

Lua
State = Space.Host.ExecutingObject.Animation.GetState()
State = Space.Host.ExecutingObject.Animation.GetState("statename")

Blend​

void Blend(string animation, float targetWeight = 1.0F, float fadeLength = 0.3F)

Blends the animation named animation towards targetWeight over the next time seconds. Playback of other animations will not be affected.

参数

名称类型默认值
animationstring–
targetWeightfloat1.0F
fadeLengthfloat0.3F

返回值

void

示例

Lua
Space.Host.ExecutingObject.Animation.Blend("animationname",1.0,0.3)

CrossFade​

void CrossFade(string animation, float fadeLength = 0.3F)

Fades the animation with name animation in over a period of time seconds and fades other animations out.

If mode is PlayMode.StopSameLayer, animations in the same layer as animation will be faded out while animation is faded in. if mode is PlayMode.StopAll, all animations will be faded out while animation is faded in.

If the animation is not set to be looping it will be stopped and rewound after playing.

参数

名称类型默认值
animationstring–
fadeLengthfloat0.3F

返回值

void

示例

Lua
Space.Host.ExecutingObject.Animation.CrossFade("animationname", 0.3)

CrossFadeQueued​

SAnimationState CrossFadeQueued(string animation, float fadeLength = 0.3F, bool playNow = false)

Returns a duplicated SAnimationState. This duplicate will self-destruct after it is finished playing. Referencing it after it has completed will result in an error.

参数

名称类型默认值
animationstring–
fadeLengthfloat0.3F
playNowboolfalse

返回值

SAnimationState

示例

Lua
NewSAnimationState = Space.Host.ExecutingObject.Animation.CrossFadeQueued("animationname", 0.3, false)

GetClipCount​

int GetClipCount()

Get the number of clips currently assigned to this animation.

返回值

int

示例

Lua
NumberOfClips = Space.Host.ExecutingObject.Animation.GetClipCount()

IsPlaying​

bool IsPlaying(string animation)

Is the animation named name playing?

参数

名称类型默认值
animationstring–

返回值

bool

示例

Lua
IsPlaying = Space.Host.ExecutingObject.Animation.IsPlaying("animationname")

Play​

bool Play()
bool Play(string animation)

Plays an animation without any blending.

If no name is supplied then the default animation will be played. In cases where the animation can't be played (ie, there is no default animation or no animation with the specified name), the function will return false.

The optional playMode lets you choose how this animation will affect others already playing.

If the specified animation is already playing then other animations will be stopped but the animation will not rewind to the beginning.

When the end of the animation is reached it will automatically be stopped and rewound to the start unless the PlayMode is set to Loop.

Note that if you call Animation.Play on an object during a frame update where the object is also deactivated then the call will effectively be cancelled; the animation will not start playing when the object is later reactivated. However, if you make the call on a subsequent frame (ie, while the object is still inactive) then the animation will start playing after reactivation.

参数

名称类型默认值
animationstring–

返回值

bool

示例

Lua
Space.Host.ExecutingObject.Animation.Play()
Space.Host.ExecutingObject.Animation.Play("animationname")

PlayQueued​

SAnimationState PlayQueued(string animation, bool playNow = false)

Returns a duplicated SAnimationState. This duplicate will self-destruct after it is finished playing. Referencing it after it has completed will result in an error.

参数

名称类型默认值
animationstring–
playNowboolfalse

返回值

SAnimationState

示例

Lua
Space.Host.ExecutingObject.Animation.PlayQueued("animationname","false")

Rewind​

void Rewind(string animation)

Rewinds the animation named name.

参数

名称类型默认值
animationstring–

返回值

void

示例

Lua
Space.Host.ExecutingObject.Animation.Rewind()

Sample​

void Sample()

Samples animations at the current state.

This is useful when you explicitly want to set up some animation state, and sample it once.

返回值

void

示例

Lua
Space.Host.ExecutingObject.Animation.Sample()

Stop​

void Stop()
void Stop(string animation)

Stops all playing animations that were started with this Animation.

Stopping an animation also Rewinds it to the Start.

参数

名称类型默认值
animationstring–

返回值

void

示例

Lua
Space.Host.ExecutingObject.Animation.Stop()
Space.Host.ExecutingObject.Animation.Stop("animationname")

属性​

Enabled​

bool Enabled {get; set; }

Whether this component is enabled or not.

示例

Lua
Space.Host.ExecutingObject.Animation.Enabled = false
Lua
--clicking this object will Enable/Disable it's Animation component
thisGameObject = Space.Host.ExecutingObject
animation = thisGameObject.Animation


OnClick = function()
animation.Enabled = not animation.Enabled
end

thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

States只读​

IDictionary< string, SAnimationState > States {get; }

Returns a table of SAnimationState names and references

示例

Lua
States = Space.Host.ExecutingObject.Animation.States

GameObject只读​

SGameObject GameObject {get; }

Returns a reference to the GameObject of this component.

示例

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