Mirror of Svelto.ECS because we're a fan of it
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NotifyComponentsRemoved.cs 780B

9 years ago
12345678910111213141516171819202122232425262728
  1. using UnityEngine;
  2. namespace Svelto.Context
  3. {
  4. public class NotifyComponentsRemoved : MonoBehaviour
  5. {
  6. public IUnityContextHierarchyChangedListener unityContext { private get; set; }
  7. void OnDestroy()
  8. {
  9. MonoBehaviour[] components = gameObject.GetComponentsInChildren<MonoBehaviour>(true);
  10. for (int i = 0; i < components.Length; ++i)
  11. if (components[i] != null)
  12. unityContext.OnMonobehaviourRemoved(components[i]);
  13. }
  14. }
  15. public class NotifyEntityRemoved : MonoBehaviour
  16. {
  17. public IUnityContextHierarchyChangedListener unityContext { private get; set; }
  18. void OnDestroy()
  19. {
  20. unityContext.OnGameObjectRemoved(gameObject);
  21. }
  22. }
  23. }