标题: AnimationCurve 用法 [打印本页] 作者: 烟雨 时间: 2015-8-30 00:16 标题: AnimationCurve 用法 今天发现这个函数,查了一下,我觉得非常实用.编辑一条任意变化的曲线用在任何你想用在的地方。 如曲线地形,曲线轨迹.基本用法是:
1.创建物体.
2.创建脚本.
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour {
public AnimationCurve anim;
}
例子就丢官方代码上来了:
public AnimationCurve anim;
private Keyframe[] ks;
void Start()
{
ks = new Keyframe[50];
int i = 0;
while (i < ks.Length)
{
ks = new Keyframe(i, i * i);
i++;
}
anim = new AnimationCurve(ks);
}
void Update()
{
transform.position = new Vector3(Time.time, anim.Evaluate(Time.time), 0);
}