public virtual bool RemoveManagedObject(ManagedObject <T> managedObject)
        {
            if (!CheckObjectIsManaged(managedObject))
            {
                return(false);
            }

            GameObject.Destroy(managedObject.gameObject);

            return(true);
        }
        public virtual bool ReleaseManagedObject(ManagedObject <T> managedObject, bool fromOnDestroy = false)
        {
            // NOTE:
            // (1) Remove reference from list when called from ManagedObject.OnDestroy.
            // (2) Destroy object when called from ReleaseManagedObject directly.

            if (fromOnDestroy)
            {
                this.managedObjects.Remove(managedObject);
            }
            else
            {
                GameObject.Destroy(managedObject);
            }

            return(true);
        }
        public virtual void ReleaseManagedObject(ManagedObject <DATA> managedObject)
        {
            // CAUTION:
            // Release must be done immediately.
            // So it must be done Remove() before GameObject.Destroy().

            if (this.IsManage(managedObject))
            {
                if (this.managedObjects.Remove(managedObject))
                {
                    // NOTE:
                    // ManagedObject.OnDestroy() will call this function again,
                    // but this.IsManage() step will be failed.

                    GameObject.Destroy(managedObject);
                }
            }
        }
 public bool CheckObjectIsManaged(ManagedObject <T> managedObject)
 {
     return(managedObject.ObjectManager == this);
 }
 public bool IsManage(ManagedObject <DATA> managedObject)
 {
     return(managedObject.Manager == this);
 }