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