zoukankan      html  css  js  c++  java
  • lightmap工具

    @MenuItem("MyPlugins/CreatLightMaterial")
    static function Apply () 
    {
         var TransformParent : Transform= Selection.activeTransform as Transform;
         var trname:String;
         var txname:String;
         var i:int=0;
         //var bumpMap : Texture;
        // var www : WWW = new WWW ("http://images.earthcam.com/ec_metros/ourcams/fridays.jpg");
         var bumpMap:Object[];
    
         //var Tr:Transform[];
         var TrArray=new Array();
         
        
         if(TransformParent==null)
         {
              EditorUtility.DisplayDialog("选择","选择一个包含子物体的Transform对象", "确定");
             return;
         }
        
         if(TransformParent.childCount==0)
         {
             EditorUtility.DisplayDialog("选择","选择的Transform对象没有子物体", "确定");
             return;
         }
         
    var Tr=TransformParent.gameObject.GetComponentsInChildren( Transform );
        bumpMap= Resources.LoadAll("New", Texture2D);
        for(var tr:Transform in Tr)
        {
            if(tr!=TransformParent)
                 { 
                     if(tr.renderer)
                         {
                             var mycolor:Color=Color(154,154,154,255);
                             var material = new Material (Shader.Find("Legacy Shaders/Lightmapped/Diffuse"));
                             if(!(tr.name+".mat"))
                                 AssetDatabase.CreateAsset(material, "Assets/Resources/New/"+tr.name+".mat");
            else { 
                        i++;
                       if(!(tr.name+i+".mat"))
                        AssetDatabase.CreateAsset(material, "Assets/Resources/New/"+tr.name+i+".mat");
                    }
                      tr.gameObject.renderer.sharedMaterial=material;
                 }
                 trname=tr.name+"VRay 完成贴图";
                 for(var tx:Texture2D in bumpMap)
                {
                     txname=tx.name;
                     if(trname==txname)
                        {
                             tr.gameObject.renderer.sharedMaterial.SetColor ("_Color",Color.gray );
                             tr.gameObject. renderer.sharedMaterial .SetTexture("_LightMap", tx);
                        
                        }  
                }
            }
        }
    }
  • 相关阅读:
    线程的五种状态
    ajax回调打开新窗体防止浏览器拦截有效方法
    mysql 如果字段为null自动返回需要的信息sql
    String 与 StringBuffer的区别
    Windows Git中文文件名乱码
    定义函数指针
    hello world
    C++析构函数调用异常问题研究
    企业开发的时候,有可能碰到的问题
    jmap
  • 原文地址:https://www.cnblogs.com/softimagewht/p/2687598.html
Copyright © 2011-2022 走看看