Skip to content

Commit 071b51f

Browse files
committed
延期释放LuaState。
1 parent 384d789 commit 071b51f

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Assets/Slua/Editor/LuaCodeGen.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,22 @@ static Startup()
6565
{
6666
EditorApplication.update += Update;
6767
// use this delegation to ensure dispose luavm at last
68-
EditorApplication.playmodeStateChanged += () =>
68+
EditorApplication.playModeStateChanged += (PlayModeStateChange state) =>
6969
{
70-
71-
if (isPlaying == true && EditorApplication.isPlaying == false)
70+
switch (state)
7271
{
73-
if (LuaState.main != null) LuaState.main.Dispose();
72+
case PlayModeStateChange.ExitingEditMode:
73+
if (isPlaying == true && EditorApplication.isPlaying == false)
74+
{
75+
if (LuaState.main != null)
76+
LuaState.main.Dispose();
77+
isPlaying = false;
78+
}
79+
break;
80+
case PlayModeStateChange.EnteredPlayMode:
81+
isPlaying = true;
82+
break;
7483
}
75-
76-
isPlaying = EditorApplication.isPlaying;
7784
};
7885
}
7986

0 commit comments

Comments
 (0)