/// <summary> /// Despawns an item in the game to be spawned in at another time in the future /// </summary> /// <param name="obj"></param> public void Despawn(SpawnableObject obj) { if (obj.isInSpawnPool) { Debug.LogError(obj.name + " was already despawned. Ignoring despawn call."); return; } int hash = obj.name.GetHashCode(); if (!spawnPoolDictionary.ContainsKey(hash)) { Debug.LogError("You are trying to despawn an object before you have initialized the spawn pool...Name: " + obj.name); return; } obj.gameObject.SetActive(false); obj.transform.SetParent(this.transform); obj.isInSpawnPool = true; obj.OnDespawnItem(); spawnPoolDictionary[hash].Enqueue(obj); }