Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
AssetPostprocessor.OnPostprocessGameObjectWithUserProperties 在导入带有用户属性的游戏物体之后
# [AssetPostprocessor](AssetPostprocessor.html).OnPostprocessGameObjectWithUserProperties 在导入带有用户属性的游戏物体之后 function *OnPostprocessGameObjectWithUserProperties* (*root* : [GameObject](../GameObject/GameObject.html), *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 } } } } ```
da
2022年5月14日 13:10
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码