找回密碼
 注冊帳號

掃一掃,訪問微社區

animationclip.setcurve 設置曲線

2014-12-31 03:06| 發布者: 楊炎| 查看: 3773| 評論: 0|原作者: 蠻牛|來自: unity3d腳本manual

摘要: animationclip.setcurve 設置曲線functionsetcurve(relativepath: string,type: type,propertyname: string,curve:animationcurve) : voidparameters參數relativepaththe path to the game object this curve applie ...

animationclip.setcurve 設置曲線

functionsetcurve(relativepath: string,type: type,propertyname: string,curve:animationcurve) : void

parameters參數

relativepath

the path to the game object this curve applies to. relativepath is formatted similar to a pathname, e.g. "root/spine/leftarm". if relativepath is empty it refers to the game object the animation clip is attached to.

應用給該曲線的游戲物體的路徑。relativepath被格式化類似路徑,如"root/spine/leftarm"。如果relativepath為空,表示動畫剪輯附加的游戲物體。

type

the class type of the component that is animated

被動畫的組件的類類型

propertyname

the name or path to the property being animated

被動畫的屬性的名字或路徑

curve

the animation curve //動畫曲線

description描述

assigns the curve to animate a specific property.

給動畫指定曲線一個特殊的屬性。

if curve is null the curve will be removed. if a curve already exists for that property, it will be replaced.

如果曲線為null,曲線將被移除,如果曲線屬性已經存在,曲線將被替換。

通常的名稱是: "localposition.x", "localposition.y", "localposition.z", "localrotation.x", "localrotation.y", "localrotation.z", "localrotation.w" "localscale.x", "localscale.y", "localscale.z".

for performance reasonstransformposition, rotation and scale can only be animated as one property.

出于性能原因,transform的position, rotation和scale 只能被動畫作為一個屬性。

c#

javascript

using unityengine;

using system.collections;

public class example :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");

}

}

// animates the x coordinate of a transform position

//動畫transform位置的x軸坐標

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)

material材質屬性可以使用shader導出的屬性名稱制作動畫。通常使用的名稱是: "_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 旋轉屬性:"propertyname.rotation"

uv 偏移和縮放: "propertyname.offset.x", "propertyname.offset.y", "propertyname.scale.x", "propertyname.scale.y"

對于在同一renderer的多個索引材質,你能想這樣添加前綴:"[1]._maintex.offset.y"

另見:clearcurves函數,animationcurve類.

c#

javascript

using unityengine;

using system.collections;

public class example :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);

}

}

// 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)

相關閱讀

文章點評
相關文章
女校游泳队彩金