public static AtlasRegion ToAtlasRegionPMAClone(this Texture2D t, Shader shader, TextureFormat textureFormat = 4, bool mipmaps = false, Material materialPropertySource = null)
        {
            Material m = new Material(shader);

            if (materialPropertySource != null)
            {
                m.CopyPropertiesFromMaterial(materialPropertySource);
                m.shaderKeywords = materialPropertySource.shaderKeywords;
            }
            Texture2D texture = t.GetClone(false, textureFormat, mipmaps);

            texture.ApplyPMA(true);
            texture.name  = t.name + "-pma-";
            m.name        = t.name + shader.name;
            m.mainTexture = texture;
            AtlasPage   page   = m.ToSpineAtlasPage();
            AtlasRegion region = texture.ToAtlasRegion(shader, 0.01f, null);

            region.page = page;
            return(region);
        }
Example #2
0
        public static AtlasRegion ToAtlasRegionPMAClone(this Texture2D t, Shader shader, TextureFormat textureFormat = TextureFormat.RGBA32, bool mipmaps = false, Material materialPropertySource = null)
        {
            Material material = new Material(shader);

            if (materialPropertySource != null)
            {
                material.CopyPropertiesFromMaterial(materialPropertySource);
                material.shaderKeywords = materialPropertySource.shaderKeywords;
            }
            Texture2D clone = t.GetClone(applyImmediately: false, textureFormat, mipmaps);

            clone.ApplyPMA();
            clone.name           = t.name + "-pma-";
            material.name        = t.name + shader.name;
            material.mainTexture = clone;
            AtlasPage   page        = material.ToSpineAtlasPage();
            AtlasRegion atlasRegion = clone.ToAtlasRegion(shader);

            atlasRegion.page = page;
            return(atlasRegion);
        }