예제 #1
0
    private IEnumerator ChangeLoginInternal(Action sceneLoadComplete = null)
    {
        GameEventManager.RaiseEvent(GameEventTypes.ExitScene);

        string sceneBundleName = string.Format("scenes/scene_login.bundle");

        Resources.UnloadUnusedAssets();

        m_operation = AssetBundleManager.LoadLevelAsync(sceneBundleName, "login", false);

        while (!m_operation.IsDone())
        {
            m_progress = m_operation.Progress;
            yield return(null);
        }

        m_operation.UnloadAssetBundle();

        AssetBundleManager.Clear();

        GameEventManager.RaiseEvent(GameEventTypes.EnterScene, 0);

        if (sceneLoadComplete != null)
        {
            sceneLoadComplete();
        }
    }
예제 #2
0
    private IEnumerator ChangeSceneInternal(int sceneCfgID, Action sceneLoadComplete = null)
    {
        GameEventManager.RaiseEvent(GameEventTypes.ExitScene);

        GameEventManager.EnableEventFiring = false;
        string assetName = ConfigManager.Get <SceneCfgLoader>().GetSceneAssetName(sceneCfgID);

        string sceneBundleName = string.Format("scenes/scene_{0}.bundle", assetName.ToLower());

        m_operation = AssetBundleManager.LoadLevelAsync(sceneBundleName, assetName, false);

        m_progress = 0f;

        while (!m_operation.IsDone())
        {
            m_progress = m_operation.Progress;
            yield return(null);
        }

        m_operation.UnloadAssetBundle();

        AssetBundleManager.Clear();

        GameEventManager.EnableEventFiring = true;

        AssetBundleManager.UnloadAssetBundle(string.Format("scenes/{0}.bundle", assetName));

        var trunkMgrGo = GameObject.FindGameObjectWithTag("SceneTrunkMgr");

        if (trunkMgrGo != null)
        {
            trunkMgr = trunkMgrGo.GetComponent <SceneTrunkMgr>();
        }

        // 等待主角周围地块加载完毕
        if (trunkMgr != null)
        {
            while (trunkMgr.HasLoadingTrunk())
            {
                yield return(null);
            }
        }

        GameEventManager.RaiseEvent(GameEventTypes.EnterScene, sceneCfgID);

        if (sceneLoadComplete != null)
        {
            sceneLoadComplete();
        }
    }