コード例 #1
0
        // with material
        public static MadMeshCombinerAtlas CreateAtlas(string texturePath, Texture2D[] textures, Shader shader)
        {
            var madeReadable = PrepareTextures(textures);
            try {
            List<MadMeshCombinerAtlas.Item> items = new List<MadMeshCombinerAtlas.Item>();

            PackTextures(textures, texturePath, ref items);

            var atlas = new MadMeshCombinerAtlas();
            atlas.atlasTexture = AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D)) as Texture2D;
            atlas.AddItemRange(items);

            // create material out of atlas
            var materialPath = System.IO.Path.ChangeExtension(texturePath, "mat");
            //var atlasMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse"));
            var atlasMaterial = new Material(shader);
            atlasMaterial.mainTexture = atlas.atlasTexture;
            atlas.atlasMaterial = atlasMaterial;

            AssetDatabase.CreateAsset(atlasMaterial, materialPath);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            return atlas;
            } finally {
            RevertAll(madeReadable);
            }
        }
コード例 #2
0
        public static Texture2D GetItemOrigin(MadMeshCombinerAtlas.Item item)
        {
            var path = AssetDatabase.GUIDToAssetPath(item.textureGUID);
            if (string.IsNullOrEmpty(path)) {
            return null;
            }

            return AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D)) as Texture2D;
        }
コード例 #3
0
        // without material
        public static MadMeshCombinerAtlas CreateAtlas(string texturePath, Texture2D[] textures)
        {
            var madeReadable = PrepareTextures(textures);
            try {
            List<MadMeshCombinerAtlas.Item> items = new List<MadMeshCombinerAtlas.Item>();

            PackTextures(textures, texturePath, ref items);

            var atlas = new MadMeshCombinerAtlas();
            atlas.atlasTexture = AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D)) as Texture2D;
            atlas.AddItemRange(items);

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            return atlas;
            } finally {
            RevertAll(madeReadable);
            }
        }
コード例 #4
0
 // ===========================================================
 // Constants
 // ===========================================================
 // ===========================================================
 // Fields
 // ===========================================================
 // ===========================================================
 // Methods for/from SuperClass/Interfaces
 // ===========================================================
 // ===========================================================
 // Methods
 // ===========================================================
 public static string GetItemOriginPath(MadMeshCombinerAtlas.Item item)
 {
     var path = AssetDatabase.GUIDToAssetPath(item.textureGUID);
     return path;
 }
コード例 #5
0
 private static List<MadMeshCombinerAtlas.Item> LiveItems(MadMeshCombinerAtlas atlas)
 {
     return (from item in atlas.items where MadMeshCombinerAtlasUtil.GetItemOrigin(item) != null select item).ToList();
 }