Exemplo n.º 1
0
    /// <summary>
    /// 获取指定的场景加载配置信息
    /// </summary>
    /// <param name="stateName"></param>
    /// <returns></returns>
    public static SceneLoadConfig GetSceneLoadConfig(string stateName)
    {
        EB.Debug.Log("[SceneLoadManager]GetSceneLoadConfig: name = {0}", stateName);

        SceneLoadConfig config = null;

        if (m_SceneLoadConfigDict != null)
        {
            m_SceneLoadConfigDict.TryGetValue(stateName, out config);
        }

        return(config);
    }
Exemplo n.º 2
0
    protected override void OnComponentEnable()
    {
        base.OnComponentEnable();
        EventManager.instance.AddListener <TapEvent>(OnTapEvent);
        EventManager.instance.AddListener <TouchStartEvent>(OnTouchStartEvent);
        EventManager.instance.AddListener <TouchUpdateEvent>(OnTouchUpdateEvent);
        EventManager.instance.AddListener <TouchEndEvent>(OnTouchEndEvent);
        EventManager.instance.AddListener <FlickEvent>(OnFlickEvent);

        //Setup camera culling mask according to PerformanceManager's config data.
        if (null != gameObject.GetComponent <Camera>())
        {
            SceneLoadConfig config = SceneLoadManager.GetSceneLoadConfig(SceneLoadManager.CurrentStateName);
            if (config != null)
            {
                uint mask = config.GetHideLayerMask();
                gameObject.GetComponent <Camera>().cullingMask = gameObject.GetComponent <Camera>().cullingMask & (int)mask;
            }
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 异步加载场景
    /// </summary>
    /// <param name="stateName">状态名称</param>
    /// <param name="begin">开始加载事件</param>
    /// <param name="failed">失败事件</param>
    /// <param name="loading">进度事件</param>
    /// <param name="finish">完成事件</param>
    public static void LoadOTALevelGroupAsync(string stateName, SceneRootEntry.Begin begin, SceneRootEntry.Failed failed, SceneRootEntry.Loading loading, SceneRootEntry.Finished finish)
    {
        //要加载的资源数据列表
        List <string> toLoad = new List <string>();
        //要卸载的资源路径列表
        List <string> toUnload = new List <string>();

        SceneLoadConfig config = GetSceneLoadConfig(stateName);

        if (config != null && config.Load != null)
        {
            m_CurrentStateName = stateName;

            // find all the scenes to be loaded
            for (int i = 0; i < config.Load.Length; ++i)
            {
                toLoad.Add(config.Load[i]);
            }

            // find all the scenes to be unloaded
            for (int i = 0; i < m_ScenesLoaded.Count; ++i)
            {
                string sceneName = m_ScenesLoaded[i];

                bool found = false;
                for (int j = 0; j < toLoad.Count; ++j)
                {
                    if (sceneName == toLoad[j])
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    toUnload.Add(sceneName);
                }
            }

            // unload all the scenes
            for (int i = 0; i < toUnload.Count; ++i)
            {
                DestroyLevel(toUnload[i]);
            }

            // hide all the scenes
            HideAll();

            // load all the scenes
            for (int i = 0; i < toLoad.Count; ++i)
            {
                if (config.Show == toLoad[i])
                {
                    m_CurrentSceneName = config.Show;
                    LoadOTALevelAsyncImpl(toLoad[i], begin, failed, loading, finish);
                }
                else
                {
                    LoadOTALevelAsyncImpl(toLoad[i], null, null, null, BackLevelLoadFinished);
                }
            }

            m_ScenesLoaded = toLoad;

            //================================================================================
            string    json    = GM.JSON.ToJson(toLoad);
            Hashtable cache   = Johny.HashtablePool.Claim();
            Hashtable content = Johny.HashtablePool.Claim();
            content["Content"] = json;
            cache["SceneLoad"] = content;
            DataLookupsCache.Instance.CacheData(cache);
            Johny.HashtablePool.Release(cache); cache = null;
            //================================================================================
        }
        else
        {
            EB.Debug.LogError("[SceneLoadManager]LoadOTALevelGroupAsync: CAN NOT find scene load config file for {0}.", stateName);
        }
    }