|
@@ -3,44 +3,184 @@ using UnityEngine;
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
using System.Collections;
|
|
|
+using System.Collections.Generic;
|
|
|
using System.Diagnostics;
|
|
|
+
|
|
|
using Debug = UnityEngine.Debug;
|
|
|
+using Object = UnityEngine.Object;
|
|
|
|
|
|
-public class Bundle : Regist
|
|
|
+public class Bundle : MonoBehaviour
|
|
|
{
|
|
|
#region
|
|
|
|
|
|
- public static bool LoadComplete;
|
|
|
-
|
|
|
public static Bundle Instance;
|
|
|
|
|
|
- public static AssetBundle UI;
|
|
|
+ public static bool LoadComplete;
|
|
|
+
|
|
|
public static AssetBundle Atlas;
|
|
|
- public static AssetBundle Effect;
|
|
|
- public static AssetBundle Audio;
|
|
|
- public static AssetBundle Scene;
|
|
|
- public static AssetBundle Config;
|
|
|
+
|
|
|
+ private static AssetBundle UI;
|
|
|
+ private static AssetBundle Effect;
|
|
|
+ private static AssetBundle Audio;
|
|
|
+ private static AssetBundle Scene;
|
|
|
+ private static AssetBundle Config;
|
|
|
+
|
|
|
+ public bool DebugMode;
|
|
|
+
|
|
|
+ public List<Object> UiList;
|
|
|
+ public List<Object> AtlasList;
|
|
|
+ public List<Object> EffectList;
|
|
|
+ public List<Object> AudioList;
|
|
|
+ public List<Object> SceneList;
|
|
|
+ public List<Object> ConfigList;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- public override void RegistImmed()
|
|
|
+ public void Awake()
|
|
|
+ {
|
|
|
+ Instance = this;
|
|
|
+
|
|
|
+ LoadAll
|
|
|
+ (
|
|
|
+ () => LoadComplete = true
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static T Load<T>(string goName, Folder folder) where T : Object
|
|
|
{
|
|
|
- if (RegistFlag)
|
|
|
+ if (Instance.DebugMode)
|
|
|
{
|
|
|
- return;
|
|
|
+ #region MyRegion
|
|
|
+
|
|
|
+ if (folder == Folder.UI)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < Instance.UiList.Count; i++)
|
|
|
+ {
|
|
|
+ if (Instance.UiList[i].name == goName)
|
|
|
+ {
|
|
|
+ return (T) Instance.UiList[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Audio)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < Instance.AudioList.Count; i++)
|
|
|
+ {
|
|
|
+ if (Instance.AudioList[i].name == goName)
|
|
|
+ {
|
|
|
+ return (T) Instance.AudioList[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Config)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < Instance.ConfigList.Count; i++)
|
|
|
+ {
|
|
|
+ if (Instance.ConfigList[i].name == goName)
|
|
|
+ {
|
|
|
+ return (T) Instance.ConfigList[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Effect)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < Instance.EffectList.Count; i++)
|
|
|
+ {
|
|
|
+ if (Instance.EffectList[i].name == goName)
|
|
|
+ {
|
|
|
+ return (T) Instance.EffectList[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Scene)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < Instance.SceneList.Count; i++)
|
|
|
+ {
|
|
|
+ if (Instance.SceneList[i].name == goName)
|
|
|
+ {
|
|
|
+ return (T) Instance.SceneList[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Atlas)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < Instance.AtlasList.Count; i++)
|
|
|
+ {
|
|
|
+ if (Instance.AtlasList[i].name == goName)
|
|
|
+ {
|
|
|
+ return (T) Instance.AtlasList[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- RegistFlag = true;
|
|
|
+ #region MyRegion
|
|
|
+
|
|
|
+ if (folder == Folder.UI)
|
|
|
+ {
|
|
|
+ return UI.LoadAsset<T>(goName);
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Audio)
|
|
|
+ {
|
|
|
+ return Audio.LoadAsset<T>(goName);
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Config)
|
|
|
+ {
|
|
|
+ return Config.LoadAsset<T>(goName);
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Effect)
|
|
|
+ {
|
|
|
+ return Effect.LoadAsset<T>(goName);
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Scene)
|
|
|
+ {
|
|
|
+ return Scene.LoadAsset<T>(goName);
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Atlas)
|
|
|
+ {
|
|
|
+ return Atlas.LoadAsset<T>(goName);
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
}
|
|
|
|
|
|
- enabled = true;
|
|
|
- Instance = this;
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
|
|
|
- LoadAll
|
|
|
- (
|
|
|
- () => LoadComplete = true
|
|
|
- );
|
|
|
+ public static AssetBundleRequest LoadAsync(string goName, Folder folder)
|
|
|
+ {
|
|
|
+ if (folder == Folder.UI)
|
|
|
+ {
|
|
|
+ return UI.LoadAssetAsync(goName);
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Audio)
|
|
|
+ {
|
|
|
+ return Audio.LoadAssetAsync(goName);
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Config)
|
|
|
+ {
|
|
|
+ return Config.LoadAssetAsync(goName);
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Effect)
|
|
|
+ {
|
|
|
+ return Effect.LoadAssetAsync(goName);
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Scene)
|
|
|
+ {
|
|
|
+ return Scene.LoadAssetAsync(goName);
|
|
|
+ }
|
|
|
+ else if (folder == Folder.Atlas)
|
|
|
+ {
|
|
|
+ return Atlas.LoadAssetAsync(goName);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -77,7 +217,7 @@ public class Bundle : Regist
|
|
|
|
|
|
yield return LoadUI();
|
|
|
|
|
|
- if (!Logo.LogoComplete)
|
|
|
+ if (!Logo.LogoComplete && !Instance.DebugMode)
|
|
|
{
|
|
|
ManaReso.AddAsyncLoad("Canvas",1,Folder.UI,ObjType.Canvas);
|
|
|
|
|
@@ -97,7 +237,7 @@ public class Bundle : Regist
|
|
|
|
|
|
yield return LoadScene();
|
|
|
|
|
|
- if (!Logo.LogoComplete)
|
|
|
+ if (!Logo.LogoComplete && !Instance.DebugMode)
|
|
|
{
|
|
|
//if (Data.GetPlayerBool("TutorialA") && Data.GetPlayerInt("TutorialIndexA") == 1)
|
|
|
//{
|
|
@@ -118,7 +258,7 @@ public class Bundle : Regist
|
|
|
|
|
|
yield return LoadAudio();
|
|
|
|
|
|
- if (!Logo.LogoComplete)
|
|
|
+ if (!Logo.LogoComplete && !Instance.DebugMode)
|
|
|
{
|
|
|
ManaReso.AddAsyncLoad("Music", 1, Folder.Audio, ObjType.Music);
|
|
|
|