예제 #1
0
        void OnPreprocessTexture()
        {
            TextureImportItem item = EditorConfig.GetTextureImportItem(assetPath);

            if (item != null)
            {
                TextureImporter textureImporter = assetImporter as TextureImporter;
                textureImporter.textureType   = item.textureType;
                textureImporter.mipmapEnabled = item.mipmapEnabled;
                if (item.textureType == TextureImporterType.Sprite)
                {
                    if (!string.IsNullOrEmpty(item.spritePackingTag))
                    {
                        textureImporter.spritePackingTag = item.spritePackingTag;
                    }

                    textureImporter.spriteImportMode = SpriteImportMode.Single;
                }

                textureImporter.isReadable = item.isReadable;

                TextureImporterPlatformSettings androidSettings = new TextureImporterPlatformSettings();
                androidSettings.name                 = "Android";
                androidSettings.overridden           = true;
                androidSettings.maxTextureSize       = item.androidMaxSize;
                androidSettings.format               = item.androidFormat;
                androidSettings.allowsAlphaSplitting = item.androidAlphaSplit;
                textureImporter.SetPlatformTextureSettings(androidSettings);

                TextureImporterPlatformSettings iosSettings = new TextureImporterPlatformSettings();
                iosSettings.name           = "iPhone";
                iosSettings.overridden     = true;
                iosSettings.maxTextureSize = item.iosMaxSize;
                iosSettings.format         = item.iosFormat;
                textureImporter.SetPlatformTextureSettings(iosSettings);
            }
        }