Renderer.materials 和sharedMaterials一些用法上的区别

Not allowed to access Renderer.materials on prefab object. Use Renderer.sharedMaterials instead
UnityEngine.Renderer:get_materials()

 

如果是Resource.Load的预制件,在代码中用.materials访问会报上述错,要new一份再使用,即 GameObject.Instantiate (res) as GameObject;

posted on 2017-04-12 16:49  jiahuafu  阅读(1495)  评论(0编辑  收藏  举报

导航