Пример #1
0
    public void ShowScene(GameSceneEnum scene)
    {
        string sceneName = scene.ToString();

        if (string.IsNullOrEmpty(sceneName))
        {
            return;
        }
        //加载Loading界面;
        if (loadingCtrl == null)
        {
            Object tempObject = ResourceMgr.Instance.LoadAssetFromAssetBundleSync(AssetType.Prefab, "Tool_Loading");
            loadingCtrl = ResourceMgr.Instance.GetAssetCtrl <LoadingController>(tempObject);
            DontDestroyOnLoad(loadingCtrl);
        }
        loadingCtrl.ShowLoading();
        if (currentScene != null)
        {
            GameObject.DestroyImmediate(currentScene);
            container.UnloadAsset();
        }
        //卸载无用资源;
        Resources.UnloadUnusedAssets();

        CoroutineMgr.Instance.StartCoroutine(ResourceMgr.Instance.LoadAssetFromAssetBundleAsync(AssetType.Prefab, sceneName,
                                                                                                go =>
        {
            if (go == null)
            {
                ShowScene(GameSceneEnum.Scene_One);
                Debug.Log(string.Format("[SceneMgr]Load Scene {0} failure!", sceneName));
                return;
            }
            currentScene = go as GameObject;
            container.AddAsset(AssetType.Prefab, sceneName);
            loadingCtrl.HideLoading();
            Debug.Log(string.Format("[SceneMgr]Load Scene {0} Success!", sceneName));
        },
                                                                                                progressValue =>
        {
            Progress = progressValue;
        }
                                                                                                ));
    }