lightmap 도구

4860 단어 map
@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);

                    

                    }  

            }

        }

    }

}

좋은 웹페이지 즐겨찾기