Suggest a change
Success!
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
Sumbission failed
For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Close
public function
SetCurve(
relativePath:
string,
type: Type,
propertyName: string,
curve:
AnimationCurve):
void;
public void
SetCurve(string
relativePath,
Type
type,
string
propertyName,
AnimationCurve curve);
public
def
SetCurve(
relativePath as string,
type as Type,
propertyName as string,
curve as
AnimationCurve)
as void
Parameters
type |
アニメーションしているコンポーネントのクラスの型 |
propertyName |
アニメーションのプロパティの名前またはパス |
curve |
アニメーションカーブ |
relativePath |
パスからcurveをゲームオブジェクトに適用します。 relativePath はpathnameに似ているフォーマットです。例: "rootrelativePath leftArm"
もし relativePath が空の場合はアニメーションクリップがアタッチされているゲームオブジェクトを指します。 |
Description
特定のプロパティのアニメーションカーブを割り当てます。
もし curve
がnullならカーブは削除されています。もしプロパティにカーブが既に存在するなら
入れ替えることになるでしょう。
一般的な名前は: "localPosition.x"
, "localPosition.y"
, "localPosition.z"
,
"localRotation.x"
, "localRotation.y"
, "localRotation.z"
, "localRotation.w"
"localScale.x"
, "localScale.y"
, "localScale.z"
.
// Animates the x coordinate of a transform position
function Start () {
// Create the curve
var curve : AnimationCurve = AnimationCurve.Linear(0, 1, 2, 3);
// Create the clip with the curve
var clip : AnimationClip = new AnimationClip();
clip.SetCurve("", Transform, "localPosition.x", curve);
// Add and play the clip
animation.AddClip(clip, "test");
animation.Play("test");
}
@script RequireComponent(Animation)
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Animation))]
public class ExampleClass : MonoBehaviour {
void Start() {
AnimationCurve curve = AnimationCurve.Linear(0, 1, 2, 3);
AnimationClip clip = new AnimationClip();
clip.SetCurve("", typeof(Transform), "localPosition.x", curve);
animation.AddClip(clip, "test");
animation.Play("test");
}
}
import UnityEngine
import System.Collections
[RequireComponent(typeof(Animation))]
public class ExampleClass(MonoBehaviour):
def Start() as void:
curve as AnimationCurve = AnimationCurve.Linear(0, 1, 2, 3)
clip as AnimationClip = AnimationClip()
clip.SetCurve('', typeof(Transform), 'localPosition.x', curve)
animation.AddClip(clip, 'test')
animation.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"
See Also: ClearCurves 関数, AnimationCurve クラス。
// Animate color's alpha and main texture's horizontal offset.
function Start () {
var clip = new AnimationClip ();
clip.SetCurve ("", Material, "_Color.a",
AnimationCurve (Keyframe(0, 0, 0, 0), Keyframe(1, 1, 0, 0)));
clip.SetCurve ("", Material, "_MainTex.offset.x",
AnimationCurve.Linear(0, 1, 2, 3));
animation.AddClip (clip, clip.name);
animation.Play(clip.name);
}
@script RequireComponent(Animation)
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Animation))]
public class ExampleClass : MonoBehaviour {
void Start() {
AnimationClip clip = new AnimationClip();
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));
animation.AddClip(clip, clip.name);
animation.Play(clip.name);
}
}
import UnityEngine
import System.Collections
[RequireComponent(typeof(Animation))]
public class ExampleClass(MonoBehaviour):
def Start() as void:
clip as AnimationClip = AnimationClip()
clip.SetCurve('', typeof(Material), '_Color.a', AnimationCurve(Keyframe(0, 0, 0, 0), Keyframe(1, 1, 0, 0)))
clip.SetCurve('', typeof(Material), '_MainTex.offset.x', AnimationCurve.Linear(0, 1, 2, 3))
animation.AddClip(clip, clip.name)
animation.Play(clip.name)