| using System.Collections; | 
| using System.Collections.Generic; | 
| using UnityEngine; | 
| using UnityEditor; | 
| using System.IO; | 
|   | 
| public class BuiltInResourceSetting | 
| { | 
|     public static void SetLaunchBackGround(string publisher, BuildTarget buildTarget) | 
|     { | 
|         var fileNames = new List<string>() { "Launch_1.png", "Launch_2.png", "Launch_3.png" }; | 
|   | 
|         for (var i = 0; i < fileNames.Count; i++) | 
|         { | 
|             var fileName = fileNames[i]; | 
|             var fromPath = "Assets/Editor/Logo/" + GetVersionName(publisher) + "/" + fileName; | 
|             var toPath = "Assets/ResourcesOut/BuiltIn/Sprites/" + fileName; | 
|             AssetDatabase.DeleteAsset(toPath); | 
|   | 
|             if (AssetDatabase.LoadAssetAtPath<Texture>(fromPath) == null) | 
|             { | 
|                 continue; | 
|             } | 
|   | 
|             AssetDatabase.CopyAsset(fromPath, toPath); | 
|   | 
|             var importerPath = toPath; | 
|             var importer = AssetImporter.GetAtPath(importerPath); | 
|             var textureImporter = importer as TextureImporter; | 
|             if (textureImporter != null) | 
|             { | 
|                 textureImporter.textureType = TextureImporterType.Sprite; | 
|                 textureImporter.spritePackingTag = string.Empty; | 
|                 textureImporter.assetBundleName = "builtin/sprites"; | 
|   | 
|                 var platformSetting = new TextureImporterPlatformSettings(); | 
|                 switch (buildTarget) | 
|                 { | 
|                     case BuildTarget.Android: | 
|                         platformSetting.overridden = true; | 
|                         platformSetting.allowsAlphaSplitting = false; | 
|                         platformSetting.name = "Android"; | 
|                         platformSetting.maxTextureSize = 1024; | 
|                         platformSetting.format = TextureImporterFormat.ETC2_RGB4; | 
|                         platformSetting.compressionQuality = 1; | 
|                         break; | 
|                     case BuildTarget.iOS: | 
|                         platformSetting.overridden = true; | 
|                         platformSetting.allowsAlphaSplitting = false; | 
|                         platformSetting.name = "iOS"; | 
|                         platformSetting.maxTextureSize = 1024; | 
|                         platformSetting.format = TextureImporterFormat.PVRTC_RGB4; | 
|                         platformSetting.compressionQuality = 1; | 
|                         break; | 
|                 } | 
|   | 
|                 textureImporter.SetPlatformTextureSettings(platformSetting); | 
|                 AssetDatabase.ImportAsset(importerPath); | 
|                 EditorUtility.SetDirty(textureImporter); | 
|             } | 
|         } | 
|     } | 
|   | 
|     public static void SetLoginBackGround(string publisher, BuildTarget buildTarget) | 
|     { | 
|         var fromPath = "Assets/Editor/Logo/" + GetVersionName(publisher) + "/LoginBackGround.png"; | 
|         var toPath = "Assets/ResourcesOut/BuiltIn/Sprites/LoginBackGround.png"; | 
|         AssetDatabase.DeleteAsset(toPath); | 
|         if (!File.Exists(Application.dataPath + "/Editor/Logo/" + GetVersionName(publisher) + "/LoginBackGround.png")) | 
|         { | 
|             return; | 
|         } | 
|         AssetDatabase.CopyAsset(fromPath, toPath); | 
|   | 
|         var importerPath = "Assets/ResourcesOut/BuiltIn/Sprites/LoginBackGround.png"; | 
|         var importer = AssetImporter.GetAtPath(importerPath); | 
|         var textureImporter = importer as TextureImporter; | 
|         if (textureImporter != null) | 
|         { | 
|             textureImporter.textureType = TextureImporterType.Sprite; | 
|             textureImporter.spritePackingTag = string.Empty; | 
|             textureImporter.assetBundleName = "builtin/sprites"; | 
|   | 
|             var platformSetting = new TextureImporterPlatformSettings(); | 
|             switch (buildTarget) | 
|             { | 
|                 case BuildTarget.Android: | 
|                     platformSetting.overridden = true; | 
|                     platformSetting.allowsAlphaSplitting = false; | 
|                     platformSetting.name = "Android"; | 
|                     platformSetting.maxTextureSize = 1024; | 
|                     platformSetting.format = TextureImporterFormat.ETC2_RGB4; | 
|                     platformSetting.compressionQuality = 1; | 
|                     break; | 
|                 case BuildTarget.iOS: | 
|                     platformSetting.overridden = true; | 
|                     platformSetting.allowsAlphaSplitting = false; | 
|                     platformSetting.name = "iOS"; | 
|                     platformSetting.maxTextureSize = 1024; | 
|                     platformSetting.format = TextureImporterFormat.PVRTC_RGB4; | 
|                     platformSetting.compressionQuality = 1; | 
|                     break; | 
|             } | 
|   | 
|             textureImporter.SetPlatformTextureSettings(platformSetting); | 
|             AssetDatabase.ImportAsset(importerPath); | 
|             EditorUtility.SetDirty(textureImporter); | 
|         } | 
|     } | 
|   | 
|     public static void SetLoginLogo(string publisher, BuildTarget buildTarget) | 
|     { | 
|         var fromPath = "Assets/Editor/Logo/" + GetVersionName(publisher) + "/TB_DL_Logo.png"; | 
|         var toPath = "Assets/ResourcesOut/BuiltIn/Sprites/TB_DL_Logo.png"; | 
|         AssetDatabase.DeleteAsset(toPath); | 
|         var root = Application.dataPath.Substring(0, Application.dataPath.Length - 6) + "/"; | 
|         File.Copy(root + fromPath, root + toPath); | 
|   | 
|         AssetDatabase.SaveAssets(); | 
|         AssetDatabase.Refresh(); | 
|   | 
|         var importerPath = "Assets/ResourcesOut/BuiltIn/Sprites/TB_DL_Logo.png"; | 
|         var importer = AssetImporter.GetAtPath(importerPath); | 
|         var textureImporter = importer as TextureImporter; | 
|         if (textureImporter != null) | 
|         { | 
|             textureImporter.textureType = TextureImporterType.Sprite; | 
|             textureImporter.spritePackingTag = string.Empty; | 
|             textureImporter.assetBundleName = "builtin/sprites"; | 
|   | 
|             var platformSetting = new TextureImporterPlatformSettings(); | 
|             switch (buildTarget) | 
|             { | 
|                 case BuildTarget.Android: | 
|                     platformSetting.overridden = true; | 
|                     platformSetting.allowsAlphaSplitting = false; | 
|                     platformSetting.name = "Android"; | 
|                     platformSetting.maxTextureSize = 512; | 
|                     platformSetting.format = TextureImporterFormat.ETC2_RGBA8; | 
|                     platformSetting.compressionQuality = 1; | 
|                     break; | 
|                 case BuildTarget.iOS: | 
|                     platformSetting.overridden = true; | 
|                     platformSetting.allowsAlphaSplitting = false; | 
|                     platformSetting.name = "iOS"; | 
|                     platformSetting.maxTextureSize = 512; | 
|                     platformSetting.format = TextureImporterFormat.PVRTC_RGBA4; | 
|                     platformSetting.compressionQuality = 1; | 
|                     break; | 
|             } | 
|   | 
|             textureImporter.SetPlatformTextureSettings(platformSetting); | 
|             AssetDatabase.ImportAsset(importerPath); | 
|             EditorUtility.SetDirty(textureImporter); | 
|         } | 
|     } | 
|   | 
|     static string GetVersionName(string _publisher) | 
|     { | 
|         var lines = File.ReadAllLines(ClientPackage.versionsFilePath); | 
|         for (int i = 2; i < lines.Length; i++) | 
|         { | 
|             var line = lines[i]; | 
|             var lineStrings = line.Split('\t'); | 
|             if (lineStrings[0] == _publisher) | 
|             { | 
|                 if (!string.IsNullOrEmpty(lineStrings[24])) | 
|                     return lineStrings[24]; | 
|                 return lineStrings[1];  | 
|             } | 
|   | 
|         } | 
|   | 
|         return string.Empty; | 
|     } | 
|   | 
| } |