Version: 2021.3

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 ();

描述

创建空的动画曲线。

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961