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]
IReadOnlyDictionary<string, string> GetPresetPaths();
void Activate();
void Deactivate();
event Action ItemChanged;
}
public interface IPathedResourceManager<T> : IResourceManager<T> {

View File

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

View File

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