お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Closeアニメーションカーブで定義されるすべてのキー。
これは明確に配列からいくつかのキーを追加または削除することが出来ます。 もし時間を基準としたソートが行われていない場合、自動的にソートが行われます。 配列は"値"による配列ということに注意してください。例えば取得するキーはすべてのキーのコピー カーブの中に設定されているキーのコピーを返しています。 See Also: Keyframe 構造体, AddKey, RemoveKey 関数.
// Make a GameObject follow a Quadratic function // Over the X and Y axis. private var anim : AnimationCurve; private var ks : Keyframe[]; function Start() { ks = new Keyframe[50]; for(var i = 0; i < ks.Length ; i++){ ks[i] = Keyframe(i,i*i); } anim = new AnimationCurve(ks); } function Update() { transform.position = Vector3(Time.time,anim.Evaluate(Time.time),0); }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { private AnimationCurve anim; private Keyframe[] ks; void Start() { ks = new Keyframe[50]; int i = 0; while (i < ks.Length) { ks[i] = new Keyframe(i, i * i); i++; } anim = new AnimationCurve(ks); } void Update() { transform.position = new Vector3(Time.time, anim.Evaluate(Time.time), 0); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): private anim as AnimationCurve private ks as (Keyframe) def Start() as void: ks = array[of Keyframe](50) i as int = 0 while i < ks.Length: ks[i] = Keyframe(i, (i * i)) i++ anim = AnimationCurve(ks) def Update() as void: transform.position = Vector3(Time.time, anim.Evaluate(Time.time), 0)