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); } }
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); } }