123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- using UnityEditor;
- using UnityEngine;
- using UnityEngine.Events;
- using System.Collections;
- [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();
- BuildPipeline.BuildAssetBundles(Application.streamingAssetsPath + "/Bundle/Android", BuildAssetBundleOptions.None, BuildTarget.Android);
- }
- [MenuItem("DashGame/Bundle/PackIOS")]
- public static void PackIOS()
- {
- Tag();
- BuildPipeline.BuildAssetBundles(Application.streamingAssetsPath + "/Bundle/IOS", BuildAssetBundleOptions.None, BuildTarget.iOS);
- }
- [MenuItem("DashGame/Bundle/PackWindows")]
- public static void PackWindows()
- {
- Tag();
- BuildPipeline.BuildAssetBundles(Application.streamingAssetsPath + "/Bundle/Windows", BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
- }
- }
|