Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

AnimationClip.SetCurve

マニュアルに切り替える
public void SetCurve(string relativePath, Type type, string propertyName, AnimationCurve curve);

パラメーター

relativePath パスから curve をゲームオブジェクトに適用します。relativePath は pathname に似ている形式です。例: "rootrelativePathleftArm" もし relativePath が空の場合はアニメーションクリップがアタッチされているゲームオブジェクトを指します。
type アニメーションしているコンポーネントのクラスの型
propertyName アニメーションのプロパティーの名前またはパス
curve アニメーションカーブ

説明

特定のプロパティーのアニメーションカーブを割り当てます。

もし curve が null ならカーブは削除されています。もしプロパティーにカーブがすでに存在するなら 入れ替えることになるでしょう。

**注意** SetCurve は 旧 AnimationClips のランタイムにのみ有効です。 旧バージョンでない AnimationClips では、これは編集専用の機能です。

一般的な名前は: "localPosition.x""localPosition.y""localPosition.z""localRotation.x""localRotation.y""localRotation.z""localRotation.w" "localScale.x""localScale.y""localScale.z".

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Animation))] public class ExampleClass : MonoBehaviour { public Animation anim; void Start() { anim = GetComponent<Animation>(); AnimationCurve curve = AnimationCurve.Linear(0, 1, 2, 3); AnimationClip clip = new AnimationClip(); clip.legacy = true; clip.SetCurve("", typeof(Transform), "localPosition.x", curve); anim.AddClip(clip, "test"); anim.Play("test"); } }

Material プロパティーはシェーダーのエクスポートされたプロパティー名を使用してアニメーションさせることができます。 一般的なプロパティーの名前は: " _MainTex""_ BumpMap"" _Color""_ SpecColor""_ Emission"。 どのようにして異なるマテリアルのプロパティータイプをアニメーションさせるか

Float プロパティー: "PropertyName"

__Vector4 プロパティー:__ "PropertyName.x""PropertyName.y""PropertyName.z""PropertyName.w"

__Color プロパティー:__ "PropertyName.r"、"PropertyName.g""PropertyName.b""PropertyName.a"

UV Rotation プロパティー: "PropertyName.rotation"

UV オフセットとスケール: "PropertyName.offset.x""PropertyName.offset.y""PropertyName.scale.x""PropertyName.scale.y"

同じレンダラー上の複合マテリアルのインデックスに、このようなプレフィックス属性をつけることができます: "[1]._MainTex.offset.y"

関連項目: ClearCurves 関数、AnimationCurve クラス。

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Animation))] public class ExampleClass : MonoBehaviour { public Animation anim; void Start() { anim = GetComponent<Animation>(); AnimationClip clip = new AnimationClip(); clip.legacy = true; clip.SetCurve("", typeof(Material), "_Color.a", new AnimationCurve(new Keyframe(0, 0, 0, 0), new Keyframe(1, 1, 0, 0))); clip.SetCurve("", typeof(Material), "_MainTex.offset.x", AnimationCurve.Linear(0, 1, 2, 3)); anim.AddClip(clip, clip.name); anim.Play(clip.name); } }

Property names can be looked up by setting Asset Serialization to Force Text mode in the Editor settings. The text files that are then written by the editor will include the names of the properties. For example, the yaml file written for a Scene object will include the Camera settings. Looking at this yaml file will show:
m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: .300000012
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
FOV パラメーターは "field of view" と言う名前で表示されています。FOV をアニメーションさせるアニメーションクリップを作成したい場合は propertyName に "field of view" を渡してください。