“AnimationTest”脚本具体了内容如下:
using UnityEngine;
public class AnimationTest : MonoBehaviour {
public Animation anim;
private float timeRecd;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.R)) {
anim.Play ("Run");
}
#region 方法一
if (Input.GetKeyDown (KeyCode.S)) {
timeRecd = anim ["Run"].time;
anim.Stop ();
}
if (Input.GetKeyDown (KeyCode.C)) {
anim ["Run"].time = timeRecd;
anim.Play ("Run");
}
#endregion
#region 方法二
if (Input.GetKeyDown (KeyCode.D)) {
anim ["Run"].speed = 0;
}
if (Input.GetKeyDown (KeyCode.F)) {
anim ["Run"].speed = 1;
}
#endregion
#region 方法三
if (Input.GetKeyDown (KeyCode.A)) {
Time.timeScale = 0;
}
if (Input.GetKeyDown (KeyCode.B)) {
Time.timeScale = 1;
}
#endregion
}
}