-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Temporary variables in Prefs are reset when the Editor's PlayMod…
…eState changes.
- Loading branch information
Showing
5 changed files
with
68 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Packages/ga.fuquna.prefsgui/Runtime/PrefsParam/PrefsParamInEditor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#if UNITY_EDITOR | ||
|
||
using UnityEditor; | ||
|
||
namespace PrefsGUI | ||
{ | ||
/// <summary> | ||
/// EditorのPlayModeが変化したときにstatic変数をクリアする | ||
/// </summary> | ||
[InitializeOnLoad] | ||
public partial class PrefsParam | ||
{ | ||
static PrefsParam() | ||
{ | ||
EditorApplication.playModeStateChanged += OnPlayModeChanged; | ||
} | ||
|
||
private static void OnPlayModeChanged(PlayModeStateChange state) | ||
{ | ||
if (state is PlayModeStateChange.ExitingPlayMode or PlayModeStateChange.ExitingEditMode) | ||
{ | ||
foreach (var prefs in All) | ||
{ | ||
prefs.Reset(); | ||
} | ||
|
||
All.Clear(); | ||
AllDic.Clear(); | ||
KeyToOnValueChangedCallback.Clear(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif |
3 changes: 3 additions & 0 deletions
3
Packages/ga.fuquna.prefsgui/Runtime/PrefsParam/PrefsParamInEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,11 @@ protected set | |
} | ||
} | ||
} | ||
|
||
private void ClearSync() | ||
{ | ||
Synced = false; | ||
onSyncedChanged = null; | ||
} | ||
} | ||
} |