Disables file watcher during gameplay.

This commit is contained in:
2023-11-20 20:24:23 +08:00
parent 4f12e4816f
commit ec8487a4c6
3 changed files with 19 additions and 0 deletions

View File

@@ -11,6 +11,9 @@ namespace Cryville.Crtr.Browsing {
[Obsolete] [Obsolete]
IReadOnlyDictionary<string, string> GetPresetPaths(); IReadOnlyDictionary<string, string> GetPresetPaths();
void Activate();
void Deactivate();
event Action ItemChanged; event Action ItemChanged;
} }
public interface IPathedResourceManager<T> : IResourceManager<T> { public interface IPathedResourceManager<T> : IResourceManager<T> {

View File

@@ -47,6 +47,14 @@ namespace Cryville.Crtr.Browsing {
ReloadFiles(); ReloadFiles();
} }
public void Activate() {
_watcher.EnableRaisingEvents = !string.IsNullOrEmpty(_watcher.Path);
}
public void Deactivate() {
_watcher.EnableRaisingEvents = false;
}
void ReloadFiles() { void ReloadFiles() {
_items = _cd.GetDirectories(); _items = _cd.GetDirectories();
_version++; _version++;

View File

@@ -23,6 +23,14 @@ namespace Cryville.Crtr.Browsing.UI {
InitDialog(); InitDialog();
} }
void OnEnable() {
ResourceManager.Activate();
}
void OnDisable() {
ResourceManager.Deactivate();
}
[Obsolete] [Obsolete]
protected void InitDialog() { protected void InitDialog() {
_dialog = Instantiate(Resources.Load<GameObject>("Common/FileDialog")).GetComponent<FileDialog>(); _dialog = Instantiate(Resources.Load<GameObject>("Common/FileDialog")).GetComponent<FileDialog>();