using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor;
using UnityEditor.SceneManagement;

namespace Vassouras.Editor
{
    // Original, lightweight meshes for Embatte's second arena. No external models.
    public static class TwilightAssets
    {
        const string Root="Assets/Vassouras";
        static string Output=>Path.GetFullPath("../artifacts/vassouras");
        static readonly Dictionary<string,Material> Mats=new Dictionary<string,Material>();
        static readonly System.Random Rng=new System.Random(91427);
        static Vector3 V(float x,float y,float z)=>new Vector3(x,y,z);
        static Color C(string value){ColorUtility.TryParseHtmlString("#"+value,out var color);return color;}
        static float Rand(float min,float max)=>min+(float)Rng.NextDouble()*(max-min);
        static GameObject Group(string name,Transform p=null){var g=new GameObject(name);if(p)g.transform.SetParent(p,false);return g;}
        static GameObject MeshObject(string name,Mesh mesh,string mat,Transform p,Vector3 position)
        {
            var g=Group(name,p);g.transform.localPosition=position;g.AddComponent<MeshFilter>().sharedMesh=mesh;
            var r=g.AddComponent<MeshRenderer>();r.sharedMaterial=Mats[mat];r.receiveShadows=true;r.shadowCastingMode=ShadowCastingMode.On;return g;
        }
        static GameObject Primitive(string name,PrimitiveType type,Vector3 scale,Vector3 pos,string mat,Transform p)
        {
            var g=GameObject.CreatePrimitive(type);g.name=name;g.transform.SetParent(p,false);g.transform.localPosition=pos;g.transform.localScale=scale;UnityEngine.Object.DestroyImmediate(g.GetComponent<Collider>());g.GetComponent<Renderer>().sharedMaterial=Mats[mat];return g;
        }
        static GameObject Box(string name,Vector3 scale,Vector3 pos,string mat,Transform p)=>Primitive(name,PrimitiveType.Cube,scale,pos,mat,p);
        static Mesh Lathe(Vector2[] profile,int sides=12)
        {
            var points=new List<Vector3>();var normals=new List<Vector3>();var uv=new List<Vector2>();var indices=new List<int>();
            for(int j=0;j<profile.Length;j++)for(int i=0;i<=sides;i++){
                float a=i*Mathf.PI*2/sides;var tangent=profile[Mathf.Min(j+1,profile.Length-1)]-profile[Mathf.Max(0,j-1)];
                points.Add(V(Mathf.Sin(a)*profile[j].x,profile[j].y,Mathf.Cos(a)*profile[j].x));
                var normal=V(Mathf.Sin(a)*tangent.y,-tangent.x,Mathf.Cos(a)*tangent.y).normalized;
                if(Mathf.Abs(profile[j].x)<.0001f)normal=j<profile.Length/2?Vector3.down:Vector3.up;
                normals.Add(normal);uv.Add(new Vector2((float)i/sides,(float)j/(profile.Length-1)));
                if(j>0&&i<sides){int b=j*(sides+1)+i,a0=b-sides-1;indices.AddRange(new[]{a0,a0+1,b+1,a0,b+1,b});}
            }
            var mesh=new Mesh{name="Turned original surface"};mesh.SetVertices(points);mesh.SetNormals(normals);mesh.SetUVs(0,uv);mesh.SetTriangles(indices,0);mesh.RecalculateBounds();return mesh;
        }
        static GameObject Cone(string name,float bottom,float top,float height,Vector3 pos,string mat,Transform p,int sides=12)
        {return MeshObject(name,Lathe(new[]{new Vector2(0,-height/2),new Vector2(bottom,-height/2),new Vector2(top,height/2),new Vector2(0,height/2)},sides),mat,p,pos);}
        static GameObject Sphere(string name,Vector3 scale,Vector3 pos,string mat,Transform p)
        {
            var profile=new List<Vector2>();for(int i=0;i<=8;i++){float a=i*Mathf.PI/8;profile.Add(new Vector2(Mathf.Sin(a)*.5f,-Mathf.Cos(a)*.5f));}
            var g=MeshObject(name,Lathe(profile.ToArray(),12),mat,p,pos);g.transform.localScale=scale;return g;
        }
        static GameObject Rod(string name,Vector3 a,Vector3 b,float radius,string mat,Transform p,int sides=8)
        {var g=Cone(name,radius,radius*.92f,Vector3.Distance(a,b),(a+b)/2,mat,p,sides);g.transform.localRotation=Quaternion.FromToRotation(Vector3.up,b-a);return g;}
        static Material Material(string name,string color,float metal=0,float rough=.8f,bool texture=false,string glow=null)
        {
            var m=new Material(Shader.Find("Standard")){name=name,color=C(color),enableInstancing=true};m.SetFloat("_Metallic",metal);m.SetFloat("_Glossiness",1-rough);
            if(texture){int n=128;var tex=new Texture2D(n,n,TextureFormat.RGB24,false);var pixels=new Color[n*n];var rand=new System.Random(name.Length*121);
                for(int y=0;y<n;y++)for(int x=0;x<n;x++){
                    float grain=(float)rand.NextDouble(),coarse=Mathf.PerlinNoise(x/19f,y/19f),v=.62f+.25f*coarse+.13f*grain;
                    if(name.Contains("Cloth"))v=.8f+(x%3==0||y%3==0?-.09f:.08f)+grain*.07f;
                    if(name=="Ashwood")v=.7f+.2f*Mathf.PerlinNoise(x/3f,y/35f)+grain*.1f;
                    pixels[y*n+x]=new Color(v,v,v,1);
                }tex.SetPixels(pixels);tex.Apply();var file=Root+"/Textures/"+name+".png";File.WriteAllBytes(file,tex.EncodeToPNG());UnityEngine.Object.DestroyImmediate(tex);AssetDatabase.ImportAsset(file);var imp=(TextureImporter)AssetImporter.GetAtPath(file);imp.isReadable=true;imp.wrapMode=TextureWrapMode.Repeat;imp.SaveAndReimport();m.mainTexture=AssetDatabase.LoadAssetAtPath<Texture2D>(file);
            }
            if(glow!=null){m.EnableKeyword("_EMISSION");m.SetColor("_EmissionColor",C(glow)*1.1f);}
            var path=Root+"/Materials/"+name+".mat";if(File.Exists(path))AssetDatabase.DeleteAsset(path);AssetDatabase.CreateAsset(m,path);Mats[name]=m;return m;
        }
        static void Materials()
        {
            Material("Basalt","424953",.08f,.87f,true);Material("EdgeStone","626777",.07f,.73f,true);Material("Moss","485e51",0,.98f,true);
            Material("Soil","1e2c32",0,.97f,true);Material("Ashwood","625446",0,.87f,true);Material("Straw","bda977",0,.92f,true);
            Material("Bronze","ba8d58",.72f,.37f);Material("Silver","a4b3bc",.7f,.34f);Material("Leather","29222c",0,.68f,true);
            Material("AmberCloth","7d4540",0,.87f,true);Material("VioletCloth","444062",0,.88f,true);Material("DarkCloth","262633",0,.9f,true);
            Material("SkinAmber","c99d83",0,.83f);Material("SkinViolet","ac897c",0,.83f);Material("HairAmber","54362f",0,.79f);Material("HairViolet","252735",0,.8f);
            Material("GoldMagic","ffc572",.12f,.36f,false,"ffb94f");Material("VioletMagic","b2a1ed",.14f,.4f,false,"a58aea");Material("Rune","829baf",.12f,.58f,false,"668694");
            Material("Ivory","d6ccae",.05f,.59f,true);Material("PaintShell","685177",.35f,.43f);
        }
        static void Combine(GameObject root)
        {
            var filters=root.GetComponentsInChildren<MeshFilter>();
            foreach(var group in filters.GroupBy(f=>f.GetComponent<Renderer>().sharedMaterial).ToArray()){
                var mesh=new Mesh{name=root.name+"_"+group.Key.name,indexFormat=IndexFormat.UInt32};
                mesh.CombineMeshes(group.Select(f=>new CombineInstance{mesh=f.sharedMesh,transform=root.transform.worldToLocalMatrix*f.transform.localToWorldMatrix}).ToArray(),true,true);
                var g=Group(group.Key.name,root.transform);g.AddComponent<MeshFilter>().sharedMesh=mesh;g.AddComponent<MeshRenderer>().sharedMaterial=group.Key;
            }
            foreach(var f in filters)UnityEngine.Object.DestroyImmediate(f.gameObject);
        }
        static GameObject Witch(string name,string team)
        {
            var g=Group(name);var p=g.transform;string cloth=team+"Cloth",skin="Skin"+team,hair="Hair"+team,metal=team=="Amber"?"Bronze":"Silver",magic=team=="Amber"?"GoldMagic":"VioletMagic";
            // A seated rider, layered coat and a hand-bound curved ash broom.
            var points=new[]{V(0,.56f,-1.2f),V(0,.58f,-.6f),V(0,.68f,.15f),V(0,.78f,.76f),V(0,.89f,1.1f)};
            for(int i=0;i<points.Length-1;i++)Rod("Curved ash broom",points[i],points[i+1],.055f,"Ashwood",p,10);
            Cone("Broom ferrule",.11f,.1f,.14f,V(0,.58f,-.63f),metal,p).transform.localRotation=Quaternion.Euler(90,0,0);
            for(int i=0;i<18;i++){float a=i*Mathf.PI*2/18,r=Rand(.08f,.25f);Rod("Bound heather bristle",V(Mathf.Sin(a)*.075f,.58f+Mathf.Cos(a)*.075f,-.66f),V(Mathf.Sin(a)*r,.47f+Mathf.Cos(a)*r,-1.65f+Rand(-.15f,.08f)),.027f,"Straw",p,5);}
            foreach(float z in new[]{-.78f,-.91f})Cone("Woven broom binding",.13f,.14f,.05f,V(0,.58f,z),"Leather",p,12).transform.localRotation=Quaternion.Euler(90,0,0);
            Sphere("Jacket torso",V(.49f,.68f,.36f),V(0,1.11f,.03f),cloth,p);
            Sphere("Seated hip",V(.5f,.25f,.38f),V(0,.77f,-.04f),"DarkCloth",p);
            // Broad coat panels form a distinct split riding cloak behind the broom.
            for(int side=-1;side<=1;side+=2){
                var coat=Cone("Split riding coat",.22f,.13f,.78f,V(side*.16f,.91f,-.31f),cloth,p,8);coat.transform.localEulerAngles=V(-27,0,side*-10);
                Rod("Coat piping",V(side*.22f,1.27f,-.21f),V(side*.31f,.58f,-.53f),.016f,metal,p,6);
                var thigh=Rod("Bent knee",V(side*.2f,.82f,.02f),V(side*.36f,.66f,.37f),.105f,"DarkCloth",p,10);
                Rod("Riding boot",V(side*.36f,.66f,.37f),V(side*.36f,.21f,.18f),.1f,"Leather",p,10);
                Sphere("Boot toe",V(.19f,.16f,.33f),V(side*.36f,.2f,.29f),"Leather",p);
                Box("Boot buckle",V(.05f,.07f,.105f),V(side*.455f,.43f,.27f),metal,p);
                Rod("Sleeve",V(side*.245f,1.28f,.02f),V(side*.25f,1.02f,.3f),.094f,cloth,p,10);
                Rod("Forearm",V(side*.25f,1.02f,.3f),V(side*.08f,.87f,.58f),.073f,cloth,p,10);
                Sphere("Leather glove",V(.13f,.13f,.15f),V(side*.08f,.87f,.6f),"Leather",p);
            }
            Cone("High leather collar",.18f,.15f,.17f,V(0,1.4f,.025f),"Leather",p,12);
            Rod("Neck",V(0,1.38f,.055f),V(0,1.55f,.055f),.09f,skin,p,10);
            Sphere("Face",V(.33f,.41f,.32f),V(0,1.67f,.07f),skin,p);
            Sphere("Hair cap",V(.37f,.36f,.3f),V(0,1.72f,-.015f),hair,p);
            for(int side=-1;side<=1;side+=2){Rod("Face framing strand",V(side*.13f,1.83f,.08f),V(side*.16f,1.43f,.0f),.038f,hair,p,8);Sphere("Eye",V(.026f,.024f,.015f),V(side*.072f,1.69f,.225f),"Leather",p);}
            Sphere("Nose",V(.056f,.1f,.08f),V(0,1.645f,.225f),skin,p);
            Rod("Necklace",V(-.13f,1.37f,.14f),V(0,1.17f,.235f),.012f,metal,p,6);Rod("Necklace",V(.13f,1.37f,.14f),V(0,1.17f,.235f),.012f,metal,p,6);
            Sphere("Compass medallion",V(.12f,.12f,.034f),V(0,1.18f,.245f),metal,p);Sphere("Medallion crystal",V(.045f,.045f,.03f),V(0,1.18f,.267f),magic,p);
            // Brim and the bent point are separate silhouettes, readable from the game camera.
            Sphere("Wide weathered brim",V(.95f,.07f,.82f),V(0,1.88f,.02f),"DarkCloth",p);
            Cone("Hat crown",.29f,.135f,.51f,V(0,2.13f,-.015f),cloth,p,14);
            var tip=Cone("Bent hat point",.14f,.009f,.37f,V(.09f,2.49f,-.045f),cloth,p,12);tip.transform.localEulerAngles=V(-13,0,-38);
            Cone("Leather hat band",.292f,.27f,.115f,V(0,1.97f,-.013f),"Leather",p,14);
            Box("Hat clasp",V(.14f,.105f,.025f),V(0,1.975f,.273f),metal,p);
            Box("Clasp inset",V(.075f,.052f,.028f),V(0,1.975f,.29f),magic,p);
            for(int i=0;i<5;i++)Sphere("Braided hair",V(.09f,.12f,.09f),V(.12f,1.52f-i*.085f,-.18f-i*.014f),hair,p);
            var pouch=Sphere("Travel satchel",V(.24f,.29f,.18f),V(-.32f,.94f,-.11f),"Leather",p);Box("Satchel clasp",V(.05f,.07f,.035f),V(-.32f,.96f,-.004f),metal,p);
            Cone("Broom charm",.055f,.015f,.2f,V(.12f,.6f,.87f),magic,p,6);
            Combine(g);return g;
        }
        static GameObject StandingStone()
        {
            var g=Group("Runestone");var p=g.transform;
            var stone=Cone("Worn standing stone",.4f,.3f,1.7f,V(0,.85f,0),"Basalt",p,7);stone.transform.localEulerAngles=V(0,12,-7);
            Box("Carved rune stem",V(.028f,.56f,.016f),V(0,1.04f,.326f),"Rune",p);
            Rod("Carved rune arm",V(-.14f,1.26f,.32f),V(0,1.08f,.329f),.018f,"Rune",p,5);
            Rod("Carved rune arm",V(.14f,.97f,.32f),V(0,1.08f,.329f),.018f,"Rune",p,5);
            Sphere("Mossy foot",V(.88f,.17f,.78f),V(0,.07f,0),"Moss",p);Combine(g);return g;
        }
        static GameObject Tree()
        {
            var g=Group("TwilightTree");var p=g.transform;
            Rod("Twisted trunk",V(0,0,0),V(.12f,2.5f,.07f),.2f,"Ashwood",p,7);
            Rod("Crooked upper trunk",V(.12f,2.2f,.07f),V(-.25f,4.05f,.15f),.1f,"Ashwood",p,7);
            for(int i=0;i<6;i++){float a=i*Mathf.PI*2/6,h=1.55f+i*.33f;var start=V(.09f,h,0);var end=V(Mathf.Cos(a)*Rand(.7f,1.3f),h+Rand(.4f,.9f),Mathf.Sin(a)*Rand(.7f,1.3f));Rod("Weathered bough",start,end,.085f,"Ashwood",p,6);Rod("Bare twig",end,end+V(Rand(-.35f,.35f),.55f,Rand(-.4f,.4f)),.035f,"Ashwood",p,5);}
            for(int i=0;i<5;i++){float a=i*Mathf.PI*2/5;Rod("Exposed root",V(0,.3f,0),V(Mathf.Sin(a)*.66f,.025f,Mathf.Cos(a)*.66f),.1f,"Ashwood",p,6);}
            Combine(g);return g;
        }
        static GameObject Brazier()
        {
            var g=Group("MoonBrazier");var p=g.transform;Cone("Stone base",.45f,.33f,.3f,V(0,.15f,0),"Basalt",p,8);
            Cone("Forged stem",.13f,.1f,.72f,V(0,.66f,0),"Bronze",p,8);Cone("Censer bowl",.18f,.42f,.27f,V(0,1.05f,0),"Bronze",p,12);
            Cone("Moon crystal",.17f,.0f,.52f,V(0,1.39f,0),"VioletMagic",p,6);Combine(g);return g;
        }
        static GameObject Environment()
        {
            var g=Group("TwilightEnvironment");var p=g.transform;
            Cone("Ancient circular foundation",9.35f,9.35f,.42f,V(0,-.25f,0),"Basalt",p,72);
            // Rings of hand-set stone pavers, merged by material into a few static meshes.
            for(int ring=0;ring<9;ring++){float radius=.55f+ring;int count=Mathf.Max(6,Mathf.RoundToInt(radius*6));
                for(int i=0;i<count;i++){float a=(i+(ring%2)*.5f)*Mathf.PI*2/count;var block=Box("Radial paving",V(.84f,.13f,.78f),V(Mathf.Sin(a)*radius,-.035f+Rand(-.012f,.012f),Mathf.Cos(a)*radius),i%13==0?"Moss":i%3==0?"EdgeStone":"Basalt",p);block.transform.localRotation=Quaternion.Euler(0,a*Mathf.Rad2Deg,0);}
            }
            for(int i=0;i<48;i++){float a=i*Mathf.PI*2/48;var curb=Box("Boundary curb",V(1.15f,.2f,.3f),V(Mathf.Sin(a)*9.15f,.01f,Mathf.Cos(a)*9.15f),"EdgeStone",p);curb.transform.localRotation=Quaternion.Euler(0,a*Mathf.Rad2Deg,0);}
            for(int i=0;i<12;i++){float a=i*Mathf.PI*2/12,r=10.05f;var stone=StandingStone();stone.transform.SetParent(p,false);stone.transform.localPosition=V(Mathf.Sin(a)*r,0,Mathf.Cos(a)*r);stone.transform.localRotation=Quaternion.Euler(0,a*Mathf.Rad2Deg+180,0);stone.transform.localScale=Vector3.one*(i%3==0?1.1f:.78f);}
            for(int i=0;i<10;i++){float a=i*Mathf.PI*2/10+.17f;var tree=Tree();tree.transform.SetParent(p,false);tree.transform.localPosition=V(Mathf.Sin(a)*12.1f,-.05f,Mathf.Cos(a)*12.1f);tree.transform.localRotation=Quaternion.Euler(0,Rand(0,360),0);tree.transform.localScale=Vector3.one*Rand(.75f,1.25f);}
            for(int i=0;i<4;i++){float a=(i+.5f)*Mathf.PI/2;var b=Brazier();b.transform.SetParent(p,false);b.transform.localPosition=V(Mathf.Sin(a)*10.15f,0,Mathf.Cos(a)*10.15f);}
            for(int i=0;i<30;i++){float a=Rand(0,Mathf.PI*2),r=Rand(9.8f,13.3f);var rock=Sphere("Scattered basalt",V(Rand(.4f,1.2f),Rand(.3f,.7f),Rand(.4f,1.1f)),V(Mathf.Sin(a)*r,.1f,Mathf.Cos(a)*r),i%3==0?"Moss":"Basalt",p);rock.transform.localEulerAngles=V(Rand(-20,20),Rand(0,180),Rand(-20,20));}
            Combine(g);return g;
        }
        static GameObject PaintCharge()
        {
            var g=Group("PaintCharge");var p=g.transform;Cone("Pigment capsule",.24f,.24f,.43f,V(0,.38f,0),"PaintShell",p,12);
            foreach(float y in new[]{.17f,.58f})Cone("Protective collar",.265f,.265f,.07f,V(0,y,0),"Ivory",p,12);
            Cone("Charge light",.248f,.248f,.1f,V(0,.38f,0),"GoldMagic",p,12);
            Cone("Valve",.08f,.07f,.13f,V(0,.685f,0),"Bronze",p,8);Rod("Pull handle",V(-.15f,.73f,0),V(.15f,.73f,0),.028f,"Leather",p,8);
            Combine(g);return g;
        }
        static void Save(GameObject g)
        {
            foreach(var f in g.GetComponentsInChildren<MeshFilter>())if(!AssetDatabase.Contains(f.sharedMesh))AssetDatabase.CreateAsset(f.sharedMesh,AssetDatabase.GenerateUniqueAssetPath(Root+"/Meshes/"+g.name+"_"+f.name+".asset"));
            PrefabUtility.SaveAsPrefabAsset(g,Root+"/Prefabs/"+g.name+".prefab");Tinta.Editor.NativeExport.Write(g,Output+"/"+g.name+".json");
        }
        static void Capture(Camera camera,string path,int width,int height)
        {
            var rt=new RenderTexture(width,height,24){antiAliasing=4};rt.Create();camera.targetTexture=rt;camera.Render();var previous=RenderTexture.active;RenderTexture.active=rt;
            var tex=new Texture2D(width,height,TextureFormat.RGB24,false);tex.ReadPixels(new Rect(0,0,width,height),0,0);tex.Apply();File.WriteAllBytes(path,tex.EncodeToPNG());camera.targetTexture=null;RenderTexture.active=previous;rt.Release();UnityEngine.Object.DestroyImmediate(rt);UnityEngine.Object.DestroyImmediate(tex);
        }
        [MenuItem("Embatte/Gerar assets Vassouras")]
        public static void Generate()
        {
            foreach(var d in new[]{"Materials","Textures","Meshes","Prefabs","Scenes"})Directory.CreateDirectory(Root+"/"+d);Directory.CreateDirectory(Output);AssetDatabase.Refresh();Mats.Clear();Materials();
            var scene=EditorSceneManager.NewScene(NewSceneSetup.EmptyScene,NewSceneMode.Single);PlayerSettings.colorSpace=ColorSpace.Linear;GraphicsSettings.defaultRenderPipeline=null;QualitySettings.renderPipeline=null;
            var assets=new[]{Witch("WitchAmber","Amber"),Witch("WitchViolet","Violet"),StandingStone(),Tree(),Brazier(),Environment(),PaintCharge()};foreach(var g in assets)Save(g);foreach(var g in assets)UnityEngine.Object.DestroyImmediate(g);
            var env=(GameObject)PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(Root+"/Prefabs/TwilightEnvironment.prefab"));
            foreach(var data in new[]{("WitchAmber",V(-1.7f,.2f,1f)),("WitchViolet",V(1.7f,.2f,-1f))}){var w=(GameObject)PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(Root+"/Prefabs/"+data.Item1+".prefab"));w.transform.position=data.Item2;w.transform.rotation=Quaternion.Euler(0,155,0);}
            RenderSettings.ambientMode=AmbientMode.Trilight;RenderSettings.ambientSkyColor=C("acb6d0")*.6f;RenderSettings.ambientEquatorColor=C("6b7799")*.4f;RenderSettings.ambientGroundColor=C("253339")*.4f;
            var sun=new GameObject("Moonlight").AddComponent<Light>();sun.type=LightType.Directional;sun.color=C("cbd7ef");sun.intensity=1.1f;sun.transform.rotation=Quaternion.Euler(55,-25,0);sun.shadows=LightShadows.Soft;
            var fill=new GameObject("Dusk rim").AddComponent<Light>();fill.type=LightType.Directional;fill.color=C("d4a5a5");fill.intensity=.32f;fill.transform.rotation=Quaternion.Euler(35,140,0);
            var camera=new GameObject("Arena camera").AddComponent<Camera>();camera.transform.position=V(0,25,16);camera.transform.LookAt(V(0,0,0));camera.fieldOfView=48;camera.backgroundColor=C("141e2a");camera.clearFlags=CameraClearFlags.SolidColor;
            EditorSceneManager.SaveScene(scene,Root+"/Scenes/CirculoDoCrepusculo.unity");AssetDatabase.SaveAssets();
            if(SystemInfo.graphicsDeviceType!=GraphicsDeviceType.Null){Capture(camera,Output+"/arena-unity.png",1200,1200);env.SetActive(false);camera.transform.position=V(6,4,8);camera.transform.LookAt(V(0,1.1f,0));camera.fieldOfView=35;Capture(camera,Output+"/witches-unity.png",1400,900);}
            AssetDatabase.ExportPackage(Root,Output+"/Vassouras-CirculoDoCrepusculo.unitypackage",ExportPackageOptions.Recurse);Debug.Log("EMBATTE_VASSOURAS_ASSETS_OK");
        }
    }
}
