asd
This commit is contained in:
@@ -128,31 +128,6 @@ namespace KCM.StateManagement.Observers
|
||||
if (this.state == null)
|
||||
return;
|
||||
|
||||
// Unity uses "fake null" for destroyed objects. Since our state is stored as object,
|
||||
// we must explicitly detect that case to avoid exceptions + log spam.
|
||||
try
|
||||
{
|
||||
UnityEngine.Object unityObj = this.state as UnityEngine.Object;
|
||||
if (this.state is UnityEngine.Object && unityObj == null)
|
||||
{
|
||||
try { StateObserver.observers.Remove(this.state.GetHashCode()); } catch { }
|
||||
try
|
||||
{
|
||||
if (observerObject != null)
|
||||
UnityEngine.Object.Destroy(observerObject);
|
||||
else
|
||||
UnityEngine.Object.Destroy(this.gameObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (!(currentMs - lastUpdate > updateInterval)) // Don't run if the update interval hasn't passed (default 100 milliseconds);
|
||||
return;
|
||||
|
||||
|
||||
@@ -12,24 +12,6 @@ namespace KCM.StateManagement.Observers
|
||||
{
|
||||
public static Dictionary<int, IObserver> observers = new Dictionary<int, IObserver>();
|
||||
|
||||
public static void ClearAll()
|
||||
{
|
||||
foreach (var observer in observers.Values)
|
||||
{
|
||||
try
|
||||
{
|
||||
var component = observer as Component;
|
||||
if (component != null)
|
||||
UnityEngine.Object.Destroy(component.gameObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
observers.Clear();
|
||||
}
|
||||
|
||||
public static void RegisterObserver<T>(T instance, string[] monitoredFields, EventHandler<StateUpdateEventArgs> eventHandler = null, EventHandler<StateUpdateEventArgs> sendUpdateHandler = null)
|
||||
{
|
||||
if (observers.ContainsKey(instance.GetHashCode()))
|
||||
|
||||
Reference in New Issue
Block a user