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.
|
- using Svelto.DataStructures;
- using UnityEngine;
-
- namespace Svelto.Context.Legacy
- {
- public class NotifyComponentsRemoved : MonoBehaviour
- {
- public WeakReference<IUnityContextHierarchyChangedListener> unityContext { private get; set; }
-
- void Start()
- {
- if (unityContext == null)
- {
- Destroy(this);
- }
- }
-
- void OnDestroy()
- {
- if (unityContext == null || unityContext.IsAlive == false)
- return;
-
- MonoBehaviour[] components = gameObject.GetComponents<MonoBehaviour>();
-
- for (int i = 0; i < components.Length; ++i)
- if (components[i] != null)
- unityContext.Target.OnMonobehaviourRemoved(components[i]);
- }
- }
- }
|