找回密码
 注册帐号

扫一扫,访问微社区

animationclip.setcurve 设置曲线

2014-12-31 03:06| 发布者: 杨炎| 查看: 3833| 评论: 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)

相关阅读

文章点评
相关文章