Skip to content

Commit

Permalink
bugfix: 修复切换场景离开事件触发不正确bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jarjin committed Feb 21, 2021
1 parent eb3a59d commit bd12a3c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions FirClient/Assets/Scripts/Utility/LuaHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FirClient.Data;
using FirClient.Define;
using FirClient.Extensions;
using LuaInterface;
using System;
using System.Collections;
Expand Down Expand Up @@ -73,16 +74,19 @@ public static void LoadLevel(LevelType levelType, LuaTable self, LuaFunction onL
/// </summary>
static IEnumerator OnLoadLevel(LevelType levelType, LuaTable self, LuaFunction onLeave, LuaFunction onEnter)
{
int levelid = (int)levelType;
var op = SceneManager.LoadSceneAsync(levelid);
Scene scene = SceneManager.GetActiveScene();
var levelName = scene.name.FirstCharToUpper();
LevelType currLevel = (LevelType)Enum.Parse(typeof(LevelType), levelName);

var op = SceneManager.LoadSceneAsync(levelType.ToString());
yield return op;
yield return new WaitForSeconds(0.1f);

if (LevelType.Loader == levelType)
{
if (onLeave != null)
{
onLeave.Call<LuaTable, LevelType, Action>(self, levelType, (Action)delegate ()
onLeave.Call<LuaTable, LevelType, Action>(self, currLevel, delegate ()
{
Util.StartCoroutine(OnLoadLevel(newLevel, self, onLeave, onEnter));
});
Expand Down

0 comments on commit bd12a3c

Please sign in to comment.