Exemplo n.º 1
0
        public static AssetScene Create(string name)
        {
            if (string.IsNullOrEmpty(name))//空场景
            {
                GameObject obj = new GameObject("AssetScene");
                if (Application.isPlaying)
                {
                    GameObject.DontDestroyOnLoad(obj);
                }
                return(obj.AddComponent <AssetScene>());
            }
            else
            {
                GameObject obj = new GameObject("AssetScene");//需要加载资源
                if (Application.isPlaying)
                {
                    GameObject.DontDestroyOnLoad(obj);
                }
                AssetScene assetScene = obj.AddComponent <AssetScene>();

                assetScene.assetBundleName = GetAssetBundleNameOfScene(name);

                Debug.Log("Load scene from AB " + assetScene.assetBundleName);
                ABsManager.Load(assetScene.assetBundleName);

                return(assetScene);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 自动清理缓存,释放内存
 /// </summary>
 /// <returns></returns>
 public static AssetScene NewScene(string name)
 {
     m_pre = m_current;
     RemovePre();
     m_current = Create(name);
     return(m_current);
 }
Exemplo n.º 3
0
        public static IEnumerator CreateAsync(string name)
        {
            if (string.IsNullOrEmpty(name))//空场景
            {
                GameObject obj = new GameObject("AssetScene");
                if (Application.isPlaying)
                {
                    GameObject.DontDestroyOnLoad(obj);
                }
                AssetScene assetScene = obj.AddComponent <AssetScene>();
                m_current = assetScene;

                yield return(null);
            }
            else
            {
                GameObject obj = new GameObject("AssetScene");//需要加载资源
                if (Application.isPlaying)
                {
                    GameObject.DontDestroyOnLoad(obj);
                }
                AssetScene assetScene = obj.AddComponent <AssetScene>();
                assetScene.assetBundleName = GetAssetBundleNameOfScene(name);
                yield return(ABsManager.LoadAsync(assetScene.assetBundleName));

                m_current = assetScene;
            }
        }
Exemplo n.º 4
0
        public static IEnumerator LoadLevelAssetBundleAsync(string name)
        {
            switch (Instance.pattern)
            {
            case Pattern.Resources:
                yield return(null);

                break;

            case Pattern.AssetBundle:
                yield return(AssetScene.NewSceneAsync(name));

                break;
            }
        }
Exemplo n.º 5
0
        public static Object Load(string path, ObjectState.State state = ObjectState.State.Normal)
        {
            Object obj = null;

            switch (Instance.pattern)
            {
            case Pattern.Resources:
                obj = Resources.Load(GetResourcesName(path));
                break;

            case Pattern.AssetBundle:
                obj = AssetScene.Load(path);
                AddABUser(obj, path, state);
                break;
            }
            return(obj);
        }
Exemplo n.º 6
0
        public static IEnumerator LoadLevelAdditiveAsync(string name, System.Action <AsyncOperation> callback = null)
        {
            switch (Instance.pattern)
            {
            case Pattern.Resources:
                yield return(UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(name, UnityEngine.SceneManagement.LoadSceneMode.Additive));

                break;

            case Pattern.AssetBundle:

                yield return(AssetScene.NewSceneAsync(name));

                yield return(UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(name, UnityEngine.SceneManagement.LoadSceneMode.Additive));

                break;
            }
        }
Exemplo n.º 7
0
        public static void LoadAsync(string path, System.Action <Object> callback)
        {
            Object obj = null;

            switch (Instance.pattern)
            {
            case Pattern.Resources:
                obj = Resources.Load(GetResourcesName(path));
                if (callback != null)
                {
                    callback(obj);
                }
                break;

            case Pattern.AssetBundle:
                Instance.StartCoroutine(AssetScene.LoadAsync(path, callback));

                break;
            }
        }
Exemplo n.º 8
0
 public static IEnumerator NewSceneAsync(string name)
 {
     m_pre = m_current;
     RemovePre();
     yield return(CreateAsync(name));
 }
Exemplo n.º 9
0
        public static IEnumerator LoadLevelAsync(string name)
        {
            yield return(AssetScene.NewSceneAsync(name));

            UnityEngine.SceneManagement.SceneManager.LoadScene(name);
        }
Exemplo n.º 10
0
 public static void Unload(string path)
 {
     AssetScene.Unload(path);
 }