Skip to content

Commit

Permalink
fix: PrefsKvsPathSelector now resets the path when Exit edit or play …
Browse files Browse the repository at this point in the history
…mode
  • Loading branch information
fuqunaga committed Apr 17, 2024
1 parent c0cf919 commit 84307eb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .idea/.idea.PrefsGUI/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 31 additions & 3 deletions Packages/PrefsGUI/Runtime/Kvs/PrefsKvsPathSelector.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using System.Linq;
using System;
using System.Linq;
using UnityEngine;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace PrefsGUI.Kvs
{
public interface IPrefsKvsPath
Expand All @@ -11,8 +16,8 @@ public interface IPrefsKvsPath

public static class PrefsKvsPathSelector
{
static bool _first = true;
static string _path;
private static bool _first = true;
private static string _path;

public static string path
{
Expand All @@ -29,5 +34,28 @@ public static string path
return _path ?? Application.persistentDataPath;
}
}

#if UNITY_EDITOR
static PrefsKvsPathSelector()
{
EditorApplication.playModeStateChanged += state =>
{
switch (state)
{
case PlayModeStateChange.ExitingEditMode:
case PlayModeStateChange.ExitingPlayMode:
_first = true;
break;

case PlayModeStateChange.EnteredEditMode:
case PlayModeStateChange.EnteredPlayMode:
break;

default:
throw new ArgumentOutOfRangeException(nameof(state), state, null);
}
};
}
#endif
}
}

0 comments on commit 84307eb

Please sign in to comment.