Animation.Play 播放

function Play (mode : PlayMode = PlayMode.StopSameLayer) : bool
function Play (animation : string, mode : PlayMode = PlayMode.StopSameLayer) : bool

Description描述

Plays animation without any blending.
没有任何混合的播放动画。

Play() will start animation with name animation, or play the default animation. The animation will be played abruptly without any blending.
Play()将开始播放名称为animation的动画,或者播放默认动画。动画会突然开始播放而没有任何混合。

If mode is PlayMode.StopSameLayer then all animations in the same layer will be stopped. If mode is PlayMode.StopAll then all animations currently playing will be stopped.
如果模式是PlayMode.StopSameLayer,那么所有在同一个层的动画将停止播放。如果模式是PlayMode.StopAll,那么所有当前在播放的动画将停止播放。

If the animation is already playing, other animations will be stopped but the animation will not rewind to the beginning.
如果动画已经在播放过程中,别的动画将停止但是动画不会回退到开始位置。

If the animation is not set to be looping it will be stopped and rewinded after playing.
如果动画没有被设置成循环模式,它将停止并且回退到开始位置。

Play() will return false if animation can't be played (no animation clip or no default animation).
如果动画不能被播放(没有动画剪辑或者没有默认动画),Play()将返回false。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		animation.Play();
	}
}
// Plays the default animation
// 播放默认动画。
animation.Play(); 

For a specific animation, you can call the animation with play as well.

对于特别的动画,你也可以调用Play来播放动画。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		animation.Play("walk");
		animation.Play("walk", PlayMode.StopAll);
	}
}
// Plays the walk animation - stops all other animations in the same layer
// 播放walk动画 - 停止同一层的其他动画。
animation.Play("walk");
// Plays the walk animation - stops all other animations
// 播放walk动画 - 停止其他动画。
animation.Play("walk", PlayMode.StopAll);
最后修改:2011年1月12日 Wednesday 23:06

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。