AnimationCurveConstructor

切换到手册
public AnimationCurve (params Keyframe[] keys);

参数

keys用于定义曲线的关键帧数组。

描述

从任意数量的关键帧创建动画曲线。

这会从可变数量的 Keyframe 参数创建曲线。如果您要从 关键帧数组创建曲线,则创建一条空曲线,然后分配 keys 属性。

using UnityEngine;
using System.Collections;

public class AnimCurveExample : MonoBehaviour { public AnimationCurve curve;

void Start() { curve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)); curve.preWrapMode = WrapMode.PingPong; curve.postWrapMode = WrapMode.PingPong; }

void Update() { transform.position = new Vector3(transform.position.x, curve.Evaluate(Time.time), transform.position.z); } }

public AnimationCurve ();

描述

创建空的动画曲线。