Exemple #1
0
        private void InternalDestroyUnit <T>(T unitComponent) where T : PUnit
        {
            if (unitComponent == null)
            {
                return;
            }

            int unitID = unitComponent.GetGOInstanceID();

            unitComponent.OnDeinit();

            PUnitPool.PutCachedOrDestroyUnit(unitComponent.gameObject, out bool isCached);
            if (!isCached)
            {
                RemoveCacheableUnitComponent(unitID);
            }
        }
Exemple #2
0
        private void InternalDestroyUnit(GameObject unitGO)
        {
            if (unitGO == null)
            {
                return;
            }

            int unitID = unitGO.GetGOInstanceID();
            var unit   = GetCacheableUnitComponent <PUnit>(unitGO);

            if (unit != null)
            {
                unit.OnDeinit();
            }

            PUnitPool.PutCachedOrDestroyUnit(unitGO, out bool isCached);
            if (!isCached)
            {
                RemoveCacheableUnitComponent(unitID);
            }
        }