首页 > 数据库技术 > 详细

unity, access material

时间:2015-05-24 06:28:32      阅读:284      评论:0      收藏:0      [点我收藏+]

 

          MeshRenderer meshRenderer=gameObject.GetComponent<MeshRenderer>();
                if(meshRenderer!=null){
                    Material material=meshRenderer.material;
                    if(material!=null){
                        do something with material
                    }
                }

参考:

1,http://forum.unity3d.com/threads/is-it-necessary-to-destroy-the-instance-material-manaully-in-unity-3-5.146946/

2,Renderer.material

public Material material;

Description
Returns the first instantiated Material assigned to the renderer.

Modifying material will change the material for this object only.

If the material is used by any other renderers, this will clone the shared material and start using it from now on.

Note:
This function automatically instantiates the materials and makes them unique to this renderer. It is your responsibility to destroy the materials when the game object is being destroyed. Resources.UnloadUnusedAssets also destroys the materials but it is usually only called when loading a new level.

 

 

 

unity, access material

原文:http://www.cnblogs.com/wantnon/p/4525291.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!