private void HandleGameObjectDestroy(GameObjectBehaviour sender, DestroyReason destroyReason) { if (Value is MonoBehaviour monoBehaviour && monoBehaviour.gameObject == sender.CachedGameObject) { Value = null; } }
private void HandleDestroyed(GameObjectBehaviour sender, DestroyReason reason) { if (reason != DestroyReason.ApplicationQuit) { return; } Invoke(new ApplicationQuitEvent()); #if UNITY_EDITOR OwningLocator?.Dispose(); #endif }
/// <inheritdoc/> public GameObjectPool.DespawnResult Despawn(GameObjectBehaviour instance) { if (!instance.TryGetValid(out instance)) { return(GameObjectPool.DespawnResult.Aborted); } if (instance.Pool.TryGetValid(out GameObjectPool pool)) { return(pool.Despawn(instance)); } instance.Destroy(); return(GameObjectPool.DespawnResult.Destroyed); }
internal static void AddCachedBehaviour(GameObjectBehaviour behaviour) { Behaviours.Add(behaviour.CachedGameObject, behaviour); }
public static bool IsPersistent(this GameObjectBehaviour behaviour) { return(IsPersistent(behaviour.CachedGameObject)); }
private void HandlePoolDestroyed(GameObjectBehaviour sender, DestroyReason reason) { RemovePool((GameObjectPool)sender, false); }