Unity動畫事件

2022-06-18 10:18:11 字數 1266 閱讀 4805

動畫事件新增

var clip = new animationclip();//clip,動畫剪輯儲存基於動畫的關鍵幀。這裡新建動畫剪輯

clip.setcurve ("", typeof(material), "_color.a", animationcurve.easeinout(0, 1, 5, 0));//給動畫指定曲線乙個特殊的屬性。

setcurve方法引數:

param1:relativepath

應用給該曲線的遊戲物體的路徑。relativepath被格式化類似路徑

,如"root/spine/leftarm"。如果relativepath為空,表示動畫剪輯附加的遊戲物體。

param2:type該動畫組建的型別。

param3:propertyname

該動畫的屬性的名字或路徑。

param4:curve

動畫曲線。

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"

var event = new animationevent();//定義動畫事件

event.time = 5;//事件觸發時間

event.functionname = "instantiateparticle";//事件**方法

clip.addevent(event);//新增此動畫時間到動畫剪輯中

animation.addclip(clip, "test");//新增此動畫剪輯到物體動畫中

Unity動畫系統 動態新增動畫事件

聽起來是不是很簡單?年輕!我一開始也是這麼認為的,後來發現這個專案使用的是dll類庫。結構如下圖 其中,rowingui是控制ui的指令碼,game是遊戲介面邏輯。game中包含rowingui的引用,可以訪問到rowingui中的類。我們的ui使用的是這樣的結構,直接把3d模型放到ui介面來顯示。...

Unity滑鼠事件

滑鼠按下事件 來判斷滑鼠那個按鍵被按下,該方法只有乙個引數,如果引數為0,則帶便滑鼠左鍵被按下,引數為1代表滑鼠右鍵被按下,引數為2代表滑鼠中鍵被按下,使用input.mouseposition引用可得到滑鼠當前位置的三維座標。if input.getmousebuttondown 0 if inp...

Unity碰撞事件

一 何為碰撞事件?當乙個用剛體控制的物體與另外乙個物體碰撞時,就會觸發碰撞事件。注 當前物體與目標物體必須帶有 collider 元件。二 碰撞事件監測方法 1.oncollisionenter collision 當碰撞開始時呼叫,只會呼叫該方法一次。2.oncollisionexit colli...