Skip to content

Commit

Permalink
Remove OnDestroy logic from SingletonHost, deprecate OnDestroy on Hos…
Browse files Browse the repository at this point in the history
…tedSingleton
  • Loading branch information
siimav committed Apr 8, 2024
1 parent fbf4be3 commit 57562b4
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions Source/ROUtils/SingletonHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public virtual void Awake() { }

public virtual void Start() { }

[Obsolete("Will never actually get destroyed. Remove at a later date.")]
public virtual void OnDestroy() { }
}

Expand Down Expand Up @@ -76,22 +77,5 @@ public void Start()
}
}
}

public void OnDestroy()
{
for (int i = _singletons.Count; i-- > 0;)
{
try
{
_singletons[i].OnDestroy();
}
catch (Exception e)
{
Debug.LogError($"Exception destroying {(_singletons[i]).GetType()}: {e}");
}
_singletons[i] = null;
}
_singletons.Clear();
}
}
}

0 comments on commit 57562b4

Please sign in to comment.