From 2feb3add98556a7b6243ba01a0119bfb5cbab259 Mon Sep 17 00:00:00 2001 From: hch <305670599@qq.com> Date: 星期五, 06 六月 2025 20:39:21 +0800 Subject: [PATCH] 0312 打包图集 --- Assets/Editor/Tool/UpdateAssetBundleName.cs | 65 +++++--------------------------- 1 files changed, 11 insertions(+), 54 deletions(-) diff --git a/Assets/Editor/Tool/UpdateAssetBundleName.cs b/Assets/Editor/Tool/UpdateAssetBundleName.cs index d08c727..2440ba9 100644 --- a/Assets/Editor/Tool/UpdateAssetBundleName.cs +++ b/Assets/Editor/Tool/UpdateAssetBundleName.cs @@ -29,12 +29,12 @@ public class UpdateSpriteSetting { - static string rootPath = Application.dataPath + "/ResourcesOut/UI/Sprite"; - static string spriteRelativePath = "Assets/ResourcesOut/UI/Sprite"; + static string rootPath = Application.dataPath + "/ResourcesOut/Sprite"; + static string spriteRelativePath = "Assets/ResourcesOut/Sprite"; public static void SetRechargeSkin(int pattern) { - var toDirectory = Application.dataPath + "/ResourcesOut/UI/Sprite/Recharge"; + var toDirectory = Application.dataPath + "/ResourcesOut/Sprite/Recharge"; var oldFiles = new DirectoryInfo(toDirectory).GetFiles("*.png", SearchOption.AllDirectories); foreach (var item in oldFiles) { @@ -55,7 +55,7 @@ { var importerPath = spriteRelativePath + Path.DirectorySeparatorChar + file.Name; var importer = AssetImporter.GetAtPath(importerPath); - importer.assetBundleName = "ui/sprite/" + file.Name.Split(".")[0].ToLower(); + importer.assetBundleName = "sprite/" + file.Name.Split(".")[0].ToLower(); // EditorUtility.SetDirty(importer); } @@ -66,7 +66,7 @@ var pathStringArray = file.DirectoryName.Split(Path.DirectorySeparatorChar); var importerPath = spriteRelativePath + Path.DirectorySeparatorChar + pathStringArray[pathStringArray.Length - 1] + Path.DirectorySeparatorChar + file.Name; var importer = AssetImporter.GetAtPath(importerPath); - importer.assetBundleName = "ui/sprite/" + pathStringArray[pathStringArray.Length - 1].ToLower(); + importer.assetBundleName = "sprite/" + pathStringArray[pathStringArray.Length - 1].ToLower(); // EditorUtility.SetDirty(importer); } @@ -81,8 +81,7 @@ public class UpdateUIWindowSetting { - static string assetRelativePath = "Assets/ResourcesOut/UI/Window"; - static string assetRelativePath2 = "Assets/ResourcesOut/UI/PriorityWindow"; + static string assetRelativePath = "Assets/ResourcesOut/UI"; [MenuItem("绋嬪簭/璁剧疆璧勬簮鍖呭悕/鏇存柊Window(All) AssetBundleName")] public static void SetAllUIWindowAssetBundleName() @@ -92,19 +91,11 @@ { var path = AssetDatabase.GUIDToAssetPath(guid); var importer = AssetImporter.GetAtPath(path); - importer.assetBundleName = "ui/window"; + importer.assetBundleName = "ui"; // EditorUtility.SetDirty(importer); } - guids = AssetDatabase.FindAssets("t:prefab", new string[] { assetRelativePath2 }); - foreach (var guid in guids) - { - var path = AssetDatabase.GUIDToAssetPath(guid); - var importer = AssetImporter.GetAtPath(path); - importer.assetBundleName = StringUtility.Contact("ui/prioritywindow/", Path.GetFileNameWithoutExtension(path).ToLower()); - // EditorUtility.SetDirty(importer); - } Debug.Log("Window璧勬簮鍖呭悕鏇存柊瀹屾垚!"); // AssetDatabase.SaveAssets(); // AssetDatabase.Refresh(); @@ -113,17 +104,9 @@ public class UpdateUIPrefabSetting { - static string prefabRootPath = Application.dataPath + "/ResourcesOut/UI/Prefab"; - static string prefabAssetRelativePath = "Assets/ResourcesOut/UI/Prefab"; + static string prefabRootPath = Application.dataPath + "/ResourcesOut/Prefab"; + static string prefabAssetRelativePath = "Assets/ResourcesOut/Prefab"; - static string bossShowRootPath = Application.dataPath + "/ResourcesOut/UI/BossShow"; - static string bossShowAssetRelativePath = "Assets/ResourcesOut/UI/BossShow"; - - static string godWeaponRootPath = Application.dataPath + "/ResourcesOut/UI/GodWeapon"; - static string godWeaponAssetRelativePath = "Assets/ResourcesOut/UI/GodWeapon"; - - static string treasureRootPath = Application.dataPath + "/ResourcesOut/UI/Treasure"; - static string treasureAssetRelativePath = "Assets/ResourcesOut/UI/Treasure"; [MenuItem("绋嬪簭/璁剧疆璧勬簮鍖呭悕/鏇存柊Prefab(All) AssetBundleName")] public static void SetAllUIPrefabAssetBundleName() @@ -133,37 +116,11 @@ { var importerPath = prefabAssetRelativePath + Path.DirectorySeparatorChar + file.Name; var importer = AssetImporter.GetAtPath(importerPath); - importer.assetBundleName = "ui/prefab"; + importer.assetBundleName = "prefab"; // EditorUtility.SetDirty(importer); } - allFiles = new DirectoryInfo(bossShowRootPath).GetFiles("*.prefab", SearchOption.TopDirectoryOnly); - foreach (var file in allFiles) - { - var importerPath = bossShowAssetRelativePath + Path.DirectorySeparatorChar + file.Name; - var importer = AssetImporter.GetAtPath(importerPath); - importer.assetBundleName = "ui/bossshow"; - // EditorUtility.SetDirty(importer); - } - - allFiles = new DirectoryInfo(godWeaponRootPath).GetFiles("*.prefab", SearchOption.TopDirectoryOnly); - foreach (var file in allFiles) - { - var importerPath = godWeaponAssetRelativePath + Path.DirectorySeparatorChar + file.Name; - var importer = AssetImporter.GetAtPath(importerPath); - importer.assetBundleName = "ui/godweapon"; - // EditorUtility.SetDirty(importer); - } - - allFiles = new DirectoryInfo(treasureRootPath).GetFiles("*.prefab", SearchOption.AllDirectories); - foreach (var file in allFiles) - { - var pathStringArray = file.DirectoryName.Split(Path.DirectorySeparatorChar); - var importerPath = treasureAssetRelativePath + Path.DirectorySeparatorChar + pathStringArray[pathStringArray.Length - 1] + Path.DirectorySeparatorChar + file.Name; - var importer = AssetImporter.GetAtPath(importerPath); - importer.assetBundleName = "ui/treasure/" + pathStringArray[pathStringArray.Length - 1].ToLower(); - // EditorUtility.SetDirty(importer); - } + Debug.Log("Prefab璧勬簮鍖呭悕鏇存柊瀹屾垚!"); // AssetDatabase.SaveAssets(); // AssetDatabase.Refresh(); -- Gitblit v1.8.0