Пример #1
0
    /// <summary>
    /// 异步加载指定的场景名称
    /// </summary>
    /// <param name="sceneFileName">场景资源名称(其实是路径带扩展名)</param>
    /// <param name="begin">开始加载事件</param>
    /// <param name="failed">失败事件</param>
    /// <param name="loading">进度事件</param>
    /// <param name="finish">完成事件</param>
    /// <returns></returns>
    static bool LoadOTALevelAsyncImpl(string sceneFileName, SceneRootEntry.Begin begin, SceneRootEntry.Failed failed, SceneRootEntry.Loading loading, SceneRootEntry.Finished finish)
    {
        EB.Debug.Log("LoadOTALevelAsyncImpl=====>");
        if (!m_SceneRootDict.ContainsKey(sceneFileName))
        {
            m_SceneRootDict.Add(sceneFileName, new SceneRootEntry(sceneFileName));
        }

        SceneRootEntry entry = null;

        m_SceneRootDict.TryGetValue(sceneFileName, out entry);
        if (entry != null)
        {
            int length = sceneFileName.IndexOf('.');
            length = (length >= 0 ? length : sceneFileName.Length);
            //场景名称
            string levelName = sceneFileName.Substring(0, length);
            string sceneUrl  = GameEngine.Instance.OtaServer + "/" + entry.m_Path;
            entry.LoadOTALevelAsync(levelName, sceneUrl, begin, failed, loading, finish);
            return(true);
        }

        EB.Debug.LogError("加载场景生成错误_[SceneLoadManager]LoadOTALevelAsync: There is no definition of level [{0}]. ", sceneFileName);
        return(false);
    }
Пример #2
0
    /// <summary>
    /// 异步加载场景
    /// </summary>
    /// <param name="levelName"></param>
    /// <param name="levelPath"></param>
    /// <param name="begin"></param>
    /// <param name="failed"></param>
    /// <param name="loading"></param>
    /// <param name="finish"></param>
    public void LoadOTALevelAsync(string levelName, string levelPath, SceneRootEntry.Begin begin, SceneRootEntry.Failed failed, SceneRootEntry.Loading loading, SceneRootEntry.Finished finish)
    {
        if (m_RootEntry != null && m_RootEntry.m_Path == levelPath)
        {
            m_CurrentLevelName = levelName;
            m_CurrentLevelPath = levelPath;
            m_OnFinished       = finish;
            HandleFinished(m_RootEntry);
        }
        else
        {
            InitLoad();

            m_CurrentLevelName = levelName;
            m_CurrentLevelPath = levelPath;
            m_OnFinished       = finish;
            m_RootEntry        = new SceneRootEntry(levelPath);
            string sceneUrl = GameEngine.Instance.OtaServer + "/" + m_RootEntry.m_Path;
            m_RootEntry.LoadOTALevelAsync(levelName, sceneUrl, begin, failed, loading, HandleFinished);
        }
    }