如果 AnimationClip 将与旧版动画组件(而不是 Animator)一起使用,则将其设置为 true。
using UnityEngine; using System.Collections;
public class animFov : MonoBehaviour { void Start() { AnimationClip fovc = new AnimationClip(); AnimationCurve curve = AnimationCurve.Linear(0.0f, 60.0f, 10.0f, 90.0f); fovc.SetCurve("", typeof(Camera), "field of view", curve); fovc.legacy = true; GetComponent<Animation>().AddClip(fovc, "animfov");
GetComponent<Animation>().Play("animfov"); } }