// /// <summary> /// 加载场景 /// </summary> /// <param name="State"></param> /// <param name="LoadSceneName"></param> /// <param name="isLogin"> </param> /// <returns></returns> private IEnumerator LoadScene(SceneBase State, string LoadSceneName, bool isLogin) { if (m_State != null) { m_State.StateEnd(); } //设置场景 m_State = State; if (isLogin) { SceneManager.LoadSceneAsync(SceneDefine.Scene_NetLoading); } else { SceneManager.LoadSceneAsync(SceneDefine.Scene_Loading); } yield return(null); Debug.Log("加载场景完成 通知新场景"); /*if (!string.IsNullOrEmpty(LoadSceneName)) * { * SceneManager.LoadScene(LoadSceneName); * yield return null; * }*/ // 通知新的场景 if (m_State != null) { m_State.StateBegin(); } }
/// <summary> /// 切换场景 /// </summary> /// <param name="State">所需要的代码</param> /// <param name="LoadSceneName">场景名称</param> /// /// <param name="isLogin"> 是否是登录切换 </param> public void SetScene(SceneBase State, string LoadSceneName, bool isLogin = false) { //加载场景 RManager.Instance.StartCoroutine(LoadScene(State, LoadSceneName, isLogin)); }