• 编辑器开发读取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);
         
                        } 
       }
      }
     }
    }

  • 相关阅读:
    UPC12617 卡片
    mcmf的dijkstra板子(来自PHY学长)
    UPC9630 Mad Veterinarian
    UPC8173【 哈希和哈希表】Three Friends
    UPC9655 Plug It In!
    UPC8428 网格VI
    UPC4248【数论】数字迷阵
    UPC4247【数论】普通递归关系
    SPOJ
    hdu 5992 Finding Hotels (kdTree)
  • 原文地址:https://www.cnblogs.com/softimagewht/p/1916823.html
Copyright © 2020-2023  润新知