U3D copy component什么意思有什么用

关于Unity 获得和使用GetComponent&MeshFilter&().mesh时的心得
我的图书馆
关于Unity 获得和使用GetComponent&MeshFilter&().mesh时的心得
今天在使用Unity3D的时候遇到了一个问题:_tesGameObject是在Project中的一个Prefab。
& & public GameObject _testGameO& & void Awake()& & {& & & & Mesh mesh=_testGameObject.GetComponent&MeshFilter&().& & & & Debug.Log(mesh.bounds.size);& & }这样使用的时候会导致将Prefab的Mesh给去掉了。所以第一次使用的时候好使。如果再次执行的时候就会遇到Prefab中的Mesh为Null了。不知道是Unity3D的一个Bug还是自己理解有误。反正感觉就是Prefab的一些属性不能直接读取,需要实例化之后才能正常读取最后:解决方法是:&public GameObject _testGameO& void Awake()& & {& & & & GameObject gameInstance = (GameObject)Instantiate(_testGameObject);& & & & gameInstance.transform.position = Vector3.& & & & gameInstance.name = _testGameObject.& & & & Mesh mesh=gameInstance.GetComponent&MeshFilter&().& & & & Debug.Log(mesh.name);& & & & Debug.Log(mesh.bounds.size);& & }
TA的最新馆藏[转]&[转]&更多数码资讯,请关注南窗数码
“编辑器工具”相关经验Unity3D的网络通讯 - 对接RoyNet的聊天室例子
- Unity3d技术 - 泰课在线 - 国内专业的Unity在线学习平台|Unity3d培训|Unity教程|Unity教程 Unreal 虚幻 AR|移动开发|美术CG|UI平面设计|前端开发 - Powered By EduSoho

我要回帖

更多关于 unity copy component 的文章

 

随机推荐