找回密码
 注册帐号

扫一扫,访问微社区

assetpostprocessor.onpostprocessgameobjectwithuserproperties 在导入带有用户属性 ...

2015-1-1 09:21| 发布者: 杨炎| 查看: 2495| 评论: 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

}

}

}

}

相关阅读

文章点评
相关文章