zoukankan      html  css  js  c++  java
  • unity, access material

     

              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.

     
  • 相关阅读:
    android判断服务是否是运行状态
    Android调用OCR识别图像中的文字
    Java生成各种条形码
    android 实现摇一摇功能
    【读书笔记】Html5游戏开发
    SpeechLib 语音播报
    罗盘
    注释文档在线编辑及生成
    系统空闲时间判断&命名验证
    Asp.Net MVC中使用ACE模板之Jqgrid
  • 原文地址:https://www.cnblogs.com/wantnon/p/4525291.html
Copyright © 2011-2022 走看看