123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- using UnityEditor;
- using UnityEngine;
- using UnityEngine.Events;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- [CustomEditor(typeof(Bundle))]
- public class EditorBundle : Editor
- {
- #region 变量
- public static Bundle Script;
- #endregion
- public void OnEnable()
- {
- Script = (Bundle) target;
- Bundle.Instance = Script;
- }
- public override void OnInspectorGUI()
- {
- base.OnInspectorGUI();
- if (GUILayout.Button("ClearTexture"))
- {
- for (int i = 0; i < Script.UiList.Count; i++)
- {
- Sprite sprite = Script.UiList[i] as Sprite;
- if (sprite == null)
- {
- Texture2D texture = Script.UiList[i] as Texture2D;
- if (texture != null)
- {
- Script.UiList.RemoveAt(i--);
- }
- }
- }
- for (int i = 0; i < Script.SceneList.Count; i++)
- {
- Sprite sprite = Script.SceneList[i] as Sprite;
- if (sprite == null)
- {
- Texture2D texture = Script.SceneList[i] as Texture2D;
- if (texture != null)
- {
- Script.SceneList.RemoveAt(i--);
- }
- }
- }
- }
- }
- public static void Tag()
- {
- //string path;
- //Bundle bundle;
- //AssetImporter assetImporter;
- //bundle = AssetDatabase.LoadAssetAtPath<Bundle>("Assets/Resource/Prefab/Object/DebugMode.prefab");
- //for (int i = 0; i < bundle.UiList.Count; i++)
- //{
- // path = AssetDatabase.GetAssetPath(bundle.UiList[i]);
- // assetImporter = AssetImporter.GetAtPath(path);
- // assetImporter.assetBundleName = "ui";
- //}
- //for (int i = 0; i < bundle.AtlasList.Count; i++)
- //{
- // path = AssetDatabase.GetAssetPath(bundle.AtlasList[i]);
- // assetImporter = AssetImporter.GetAtPath(path);
- // assetImporter.assetBundleName = "atlas";
- //}
- //for (int i = 0; i < bundle.EffectList.Count; i++)
- //{
- // path = AssetDatabase.GetAssetPath(bundle.EffectList[i]);
- // assetImporter = AssetImporter.GetAtPath(path);
- // assetImporter.assetBundleName = "effect";
- //}
- //for (int i = 0; i < bundle.AudioList.Count; i++)
- //{
- // path = AssetDatabase.GetAssetPath(bundle.AudioList[i]);
- // assetImporter = AssetImporter.GetAtPath(path);
- // assetImporter.assetBundleName = "audio";
- //}
- //for (int i = 0; i < bundle.SceneList.Count; i++)
- //{
- // path = AssetDatabase.GetAssetPath(bundle.SceneList[i]);
- // assetImporter = AssetImporter.GetAtPath(path);
- // assetImporter.assetBundleName = "scene";
- //}
- //for (int i = 0; i < bundle.ConfigList.Count; i++)
- //{
- // path = AssetDatabase.GetAssetPath(bundle.ConfigList[i]);
- // assetImporter = AssetImporter.GetAtPath(path);
- // assetImporter.assetBundleName = "config";
- //}
- //for (int i = 0; i < bundle.DiscardList.Count; i++)
- //{
- // path = AssetDatabase.GetAssetPath(bundle.DiscardList[i]);
- // assetImporter = AssetImporter.GetAtPath(path);
- // assetImporter.assetBundleName = "config";
- //}
- }
- [MenuItem("DashGame/Bundle/PackAndroid")]
- public static void PackAndroid()
- {
- Tag();
- string prefix = Application.streamingAssetsPath + "/Bundle/Android";
- BuildPipeline.BuildAssetBundles(prefix, BuildAssetBundleOptions.ForceRebuildAssetBundle, BuildTarget.Android);
- Move(prefix, BuildTarget.Android);
- }
- [MenuItem("DashGame/Bundle/PackIOS")]
- public static void PackIOS()
- {
- Tag();
- string prefix = Application.streamingAssetsPath + "/Bundle/IOS";
- BuildPipeline.BuildAssetBundles(prefix, BuildAssetBundleOptions.ForceRebuildAssetBundle, BuildTarget.iOS);
- Move(prefix, BuildTarget.iOS);
- }
- [MenuItem("DashGame/Bundle/PackWindows")]
- public static void PackWindows()
- {
- Tag();
- string prefix = Application.streamingAssetsPath + "/Bundle/Windows";
- BuildPipeline.BuildAssetBundles(prefix, BuildAssetBundleOptions.ForceRebuildAssetBundle, BuildTarget.StandaloneWindows64);
- Move(prefix, BuildTarget.StandaloneWindows64);
- }
- private static void Move(string prefix, BuildTarget buildTarget)
- {
- List<string> names = new List<string>
- {
- "config",
- "new_dress_tex",
- "new_dress_ske",
- //"new_dress_config",
- //"new_language_config",
- //"new_flower_config",
- "new_flower_tex",
- };
- foreach (var name in names)
- {
- File.Delete($"{prefix}/HotUpdate/{name}");
- File.Delete($"{prefix}/HotUpdate/{name}.meta");
- File.Delete($"{prefix}/HotUpdate/{name}.manifest");
- File.Delete($"{prefix}/HotUpdate/{name}.manifest.meta");
- File.Move($"{prefix}/{name}", $"{prefix}/HotUpdate/{name}");
- File.Move($"{prefix}/{name}.manifest", $"{prefix}/HotUpdate/{name}.manifest");
- if (File.Exists($"{prefix}/{name}.meta"))
- {
- File.Move($"{prefix}/{name}.meta", $"{prefix}/HotUpdate/{name}.meta");
- }
- if (File.Exists($"{prefix}/{name}.manifest.meta"))
- {
- File.Move($"{prefix}/{name}.manifest.meta", $"{prefix}/HotUpdate/{name}.manifest.meta");
- }
- }
- string hotUpdateFolder = null;
- if (buildTarget == BuildTarget.Android)
- {
- hotUpdateFolder = Application.dataPath + "/HotUpdate/Android";
- }
- else if (buildTarget == BuildTarget.iOS)
- {
- hotUpdateFolder = Application.dataPath + "/HotUpdate/IOS";
- }
- else if (buildTarget == BuildTarget.StandaloneWindows64)
- {
- hotUpdateFolder = Application.dataPath + "/HotUpdate/Windows";
- }
- if (!string.IsNullOrEmpty(hotUpdateFolder))
- {
- foreach (var name in names)
- {
- byte[] bytes = File.ReadAllBytes($"{prefix}/HotUpdate/{name}");
- File.WriteAllBytes(hotUpdateFolder + "/" + name, bytes);
- }
- }
- AssetDatabase.Refresh();
- }
- }
|