Esempio n. 1
0
    /// <summary>
    /// 封装加载场景的方法
    /// </summary>
    /// <param name="levelName">要加载的场景名</param>
    /// <param name="needShowLoadScene">是否需要过度一个加载场景,默认为true</param>
    public void LoadScene(string levelName, bool needShowLoadScene = true)
    {
        ExitSceneArgs e = new ExitSceneArgs();

        e.nextSceneName     = levelName;
        e.needShowLoadScene = needShowLoadScene;
        //发送退出当前场景的消息
        SendEvent(Consts.E_ExitScene, e);
    }
Esempio n. 2
0
    /// <summary>
    /// 当一个场景要离开时
    /// </summary>
    /// <param name="data"></param>
    public override void Excute(object data)
    {
        //保存好玩家在这个场景的位置
        if (Game.EnterGameScene)
        {
            SavePlayerPos();
        }

        ExitSceneArgs e = data as ExitSceneArgs;

        Game.CurrentSceneName = e.nextSceneName;

        if (e.needShowLoadScene)
        {
            //加载Loading场景
            SceneManager.LoadScene("LoadScene");
        }
        else
        {
            SceneManager.LoadScene(e.nextSceneName);
        }
    }