找回密碼
 注冊帳號

掃一掃,訪問微社區

assetpostprocessor.onpostprocessgameobjectwithuserproperties 在導入帶有用戶屬性 ...

2015-1-1 09:21| 發布者: 楊炎| 查看: 2467| 評論: 0|原作者: 蠻牛|來自: unity3d腳本manual

摘要: assetpostprocessor.onpostprocessgameobjectwithuserproperties 在導入帶有用戶屬性的游戲物體之后functiononpostprocessgameobjectwithuserproperties(root:gameobject,propnames: string,values: object) : voidd ...

assetpostprocessor.onpostprocessobject" target="_blank" class="relatedlink">gameobjectwithuserproperties 在導入帶有用戶屬性游戲物體之后

functiononpostprocessgameobjectwithuserproperties(root:gameobject,propnames: string[],values: object[]) : void

description描述

gets called for each gameobject that had at least one userpropery attached to it in the imported file.

在導入文件中,為每個至少附加了一個用戶屬性的游戲物體調用。

the propnames is a string[] containing all the names of the properties found. the values is an system.object[] containing all the actual values. these can be of type string, vector4, bool, string, color, float, int.

propnames是一個string[],其中包含了所有找到的屬性的名稱.該值是一個object[],包含所有實際值。它們可以是string,vector4, bool, string, color, float, int。

typical usecase for this feature is reading out "userdata" stored on objects in 3dmax/maya. based on what is written in the text userdata for an object, you could decide to postprocess your gameobject in different ways. the sample below adds a simple boxcollider component if the userdata string contains "addboxcollider".

典型的運用是從存儲在3dmax/maya的對象中讀取”userdata”,基于什么用戶數據被寫入到對象,你可以用不同的方式來后處理游戲物體。下面的例子中,如果用戶數據字符串包含”addboxcollider”,就添加一個boxcollider組件。

class mypostprocessor extends assetpostprocessor {

function onpostprocessgameobjectwithuserproperties (

go :gameobject,

propnames :string[],

values : system.object[]

)

{

for (var i : int =0; i!= propnames.length; i++)

{

var propname :string= propnames[i];

var value :object= values[i];

debug.log("propname: "+propname+" value: "+values[i]);

if (value.gettype() ==string)

{

var s :string= value;

if (s.contains("addboxcollider")) go.addcomponent(boxcollider);

}

if (value.gettype() ==vector4)

{

var v :vector4= value;

// do something useful.

}

if (value.gettype() == color )

{

var c :color= value;

// do something useful.

}

if (value.gettype() == int)

{

var myint : int = value;

// do something useful.

}

if (value.gettype() == float)

{

var myfloat : float = value;

// do something useful

}

}

}

}

相關閱讀

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