Exemple #1
0
    public void ChangeScene(int sceneID)
    {
        //当前有场景正在加载,那么就加入到loading栈
        if (curScene != null && curScene.State == CSceneState.Loading)
        {
            loadSceneStack.Push(sceneID);
        }
        else
        {
            // CGameCore
            var data = CDatabase.Instance.GetData <CTableScene>(sceneID);

            // CAssetsManager.Instance.LoadAssetAsync(data.name, data.resPath, (asset)=>{
            if (curScene != null)
            {
                curScene.Dispose();
            }

            CSceneBase scene;
            if (!dicScene.TryGetValue(data.id, out scene))
            {
                scene = new CSceneBase();
                scene.Init();
                dicScene.Add(data.id, scene);
            }
            scene.State = CSceneState.Loading;
            curScene    = scene;

            OnSceneLoaded(scene);
            // UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(data.name);
            // });
        }
    }
Exemple #2
0
 private void OnSceneLoaded(CSceneBase scene)
 {
     if (scene == curScene)
     {
         curScene.State = CSceneState.Active;
         curScene.OnLoaded();
     }
 }