From 5bbcb15dc081ede6e6d390c81e7ec64901a1988a Mon Sep 17 00:00:00 2001
From: cehua_Czg <tingame100@163.com>
Date: 星期一, 22 四月 2019 16:30:34 +0800
Subject: [PATCH] 6666 第一章NPC配置

---
 Assets/Editor/Tool/BuiltInResourceSetting.cs |   97 ++++++++++++++++++++++++++++--------------------
 1 files changed, 56 insertions(+), 41 deletions(-)

diff --git a/Assets/Editor/Tool/BuiltInResourceSetting.cs b/Assets/Editor/Tool/BuiltInResourceSetting.cs
index e1379a5..1191f5b 100644
--- a/Assets/Editor/Tool/BuiltInResourceSetting.cs
+++ b/Assets/Editor/Tool/BuiltInResourceSetting.cs
@@ -8,63 +8,78 @@
 {
     public static void SetLaunchBackGround(string publisher, BuildTarget buildTarget)
     {
-        var fromPath = "Assets/Editor/Logo/" + GetVersionName(publisher) + "/Launch.png";
-        var toPath = "Assets/Resources/UI/Sprites/Launch.png";
-        AssetDatabase.DeleteAsset(toPath);
-        AssetDatabase.CopyAsset(fromPath, toPath);
+        var fileNames = new List<string>() { "Launch_1.png", "Launch_2.png", "Launch_3.png" };
 
-        var importerPath = "Assets/Resources/UI/Sprites/Launch.png";
-        var importer = AssetImporter.GetAtPath(importerPath);
-        var textureImporter = importer as TextureImporter;
-        if (textureImporter != null)
+        for (var i = 0; i < fileNames.Count; i++)
         {
-            textureImporter.textureType = TextureImporterType.Sprite;
-            textureImporter.spritePackingTag = string.Empty;
-            textureImporter.assetBundleName = string.Empty;
+            var fileName = fileNames[i];
+            var fromPath = "Assets/Editor/Logo/" + GetVersionName(publisher) + "/" + fileName;
+            var toPath = "Assets/ResourcesOut/BuiltIn/Sprites/" + fileName;
+            AssetDatabase.DeleteAsset(toPath);
 
-            var platformSetting = new TextureImporterPlatformSettings();
-            switch (buildTarget)
+            if (AssetDatabase.LoadAssetAtPath<Texture>(fromPath) == null)
             {
-                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_RGBA4;
-                    platformSetting.compressionQuality = 1;
-                    break;
+                continue;
             }
 
-            textureImporter.SetPlatformTextureSettings(platformSetting);
-            AssetDatabase.ImportAsset(importerPath);
-            EditorUtility.SetDirty(textureImporter);
-        }
+            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/sprite";
+
+                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/Resources/UI/Sprites/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/Resources/UI/Sprites/LoginBackGround.png";
+        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 = string.Empty;
+            textureImporter.assetBundleName = "builtin/sprite";
 
             var platformSetting = new TextureImporterPlatformSettings();
             switch (buildTarget)
@@ -82,7 +97,7 @@
                     platformSetting.allowsAlphaSplitting = false;
                     platformSetting.name = "iOS";
                     platformSetting.maxTextureSize = 1024;
-                    platformSetting.format = TextureImporterFormat.PVRTC_RGBA4;
+                    platformSetting.format = TextureImporterFormat.PVRTC_RGB4;
                     platformSetting.compressionQuality = 1;
                     break;
             }
@@ -96,18 +111,18 @@
     public static void SetLoginLogo(string publisher, BuildTarget buildTarget)
     {
         var fromPath = "Assets/Editor/Logo/" + GetVersionName(publisher) + "/TB_DL_Logo.png";
-        var toPath = "Assets/ResourcesOut/BuiltIn/UI/Sprites/TB_DL_Logo.png";
+        var toPath = "Assets/ResourcesOut/BuiltIn/Sprites/TB_DL_Logo.png";
         AssetDatabase.DeleteAsset(toPath);
         AssetDatabase.CopyAsset(fromPath, toPath);
 
-        var importerPath = "Assets/Resources/UI/Sprites/TB_DL_Logo.png";
+        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 = string.Empty;
+            textureImporter.assetBundleName = "builtin/sprite";
 
             var platformSetting = new TextureImporterPlatformSettings();
             switch (buildTarget)
@@ -145,7 +160,7 @@
             var lineStrings = line.Split('\t');
             if (lineStrings[0] == _publisher)
             {
-               return lineStrings[1];
+                return lineStrings[1];
             }
         }
 

--
Gitblit v1.8.0