Version: 2019.1

KeyframeConstructor

Switch to Manual
public Keyframe (float time, float value);

Description

Create a keyframe.

using UnityEngine;

public class Example : MonoBehaviour { // Make a GameObject follow a Sinus function // Over the X and Y axis.

AnimationCurve anim; Keyframe[] ks;

void Start() { ks = new Keyframe[50]; for (var i = 0; i < ks.Length; i++) { ks[i] = new Keyframe(i, Mathf.Sin(i)); } anim = new AnimationCurve(ks); }

void Update() { transform.position = new Vector3(Time.time, anim.Evaluate(Time.time), 0); } }

public Keyframe (float time, float value, float inTangent, float outTangent);

Description

Create a keyframe.

using UnityEngine;

public class Example : MonoBehaviour { // Make a GameObject follow a Sinus function // Over the X and Y axis.

AnimationCurve anim; Keyframe[] ks;

void Start() { ks = new Keyframe[50]; for (var i = 0; i < ks.Length; i++) { ks[i] = new Keyframe(i, Mathf.Sin(i), 90, 90); } anim = new AnimationCurve(ks); }

void Update() { transform.position = new Vector3(Time.time, anim.Evaluate(Time.time), 0); } }

public Keyframe (float time, float value, float inTangent, float outTangent, float inWeight, float outWeight);

Description

Create a keyframe.

using UnityEngine;

public class Example : MonoBehaviour { // Make a GameObject follow a Sinus function // Over the X and Y axis.

AnimationCurve anim; Keyframe[] ks;

void Start() { ks = new Keyframe[50]; for (var i = 0; i < ks.Length; i++) { ks[i] = new Keyframe(i, Mathf.Sin(i), 0, 0, 0, 0); } anim = new AnimationCurve(ks); }

void Update() { transform.position = new Vector3(Time.time, anim.Evaluate(Time.time), 0); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961