void Generate() { var mats = typeof(PowderSim.MaterialID).GetEnumNames().Select(enum_name => Materials.FirstOrDefault(m => m.EnumName == enum_name) ?? new MaterialInfo { EnumName = enum_name, Texture = DefaultTexture } ).ToArray(); var Textures = new List <Texture2D>(); foreach (var mat in mats) { mat.TextureIndex = -1; if (mat.Texture != null) { mat.TextureIndex = Textures.IndexOf(mat.Texture); if (mat.TextureIndex < 0) { mat.TextureIndex = Textures.Count; Textures.Add(mat.Texture); } } } Sim.MaterialTexArray = TextureArrayCreator.CreateTextureArray(Textures.ToArray(), "MaterialsTexArray"); Sim.ShadingTexArray = TextureArrayCreator.CreateTextureArray(ShadingTextures.ToArray(), "ShadingTexArray"); Sim.MaterialTextureIndecies = mats.Select(x => (float)x.TextureIndex).ToArray(); Sim.MaterialShadingModes = mats.Select(x => (float)x.ShadingMode).ToArray(); AssetDatabase.CreateAsset(Sim.MaterialTexArray, "Assets/MaterialsTexArray.asset"); AssetDatabase.CreateAsset(Sim.ShadingTexArray, "Assets/ShadingTexArray.asset"); }
static void Init() { TextureArrayCreator window = (TextureArrayCreator)EditorWindow.GetWindow(typeof(TextureArrayCreator)); window.Show(); }