Ejemplo n.º 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();
        }
    }
Ejemplo n.º 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();
        }
    }
Ejemplo n.º 3
0
    // Load level from the given assetBundle.
    public static AMLoadOperation LoadLevelAsync(string assetBundleName, string levelName, bool isAdditive)
    {
        AMLoadOperation operation = null;

#if UNITY_EDITOR
        if (SimulateAssetBundleInEditor)
        {
            operation = new AssetBundleLoadLevelSimulationOperation(assetBundleName, levelName, isAdditive);
        }
        else
#endif
        {
            LoadAssetBundle(assetBundleName, false);
            operation = new AssetBundleLoadLevelOperation(assetBundleName, levelName, isAdditive);

            m_inProgressOperations.Add(operation);
        }

        return(operation);
    }
Ejemplo n.º 4
0
 protected void AutoUnloadAsset(AMLoadOperation loadOp)
 {
     loadOps.Add(loadOp);
 }