public GameObject GetObject(SpawnerBase spawner, SpawnerCategoryInfo category) { GameObjectPool pool; var exists = _pools.TryGetValue(category, out pool); if (exists == false) { pool = new GameObjectPool(category.prefab, spawner.spawnerInfo.poolSize); _pools[category] = pool; } return(pool.Get()); }
public void DestroyObject(SpawnerBase spawner, SpawnerCategoryInfo category, GameObject obj) { #if UNITY_EDITOR if (Application.isPlaying == false) { UnityEngine.Object.DestroyImmediate(obj); } else { UnityEngine.Object.Destroy(obj); } #else UnityEngine.Object.Destroy(obj); #endif }
public Vector3 GetPointInVolume(SpawnerBase spawner, SpawnerCategoryInfo category) { Assert.IsNotNull(distributionTexture, "Distribution texture is null, this isn't allowed!"); Vector2 outValue = new Vector2(); GetRandomValueFromSpatialTreeRecursive(rootCell, distributionTexture.width, distributionTexture.height, ref outValue); // Normalize outValue outValue.x /= rootCell.width; outValue.y /= rootCell.height; outValue.x *= volumeSize.x; outValue.y *= volumeSize.y; outValue.x -= volumeSize.x / 2f; outValue.y -= volumeSize.y / 2f; return(new Vector3(outValue.x, 0f, outValue.y)); }
public void DestroyObject(SpawnerBase spawner, SpawnerCategoryInfo category, GameObject obj) { _pools[category].Destroy(obj); }
public Vector3 GetPointInVolume(SpawnerBase spawner, SpawnerCategoryInfo category) { return(UnityEngine.Random.insideUnitSphere * _radius + Vector3.up * (_radius / 2f)); // + offset to spawn above the lower half of the sphere }
public GameObject GetObject(SpawnerBase spawner, SpawnerCategoryInfo category) { return(UnityEngine.Object.Instantiate <GameObject>(category.prefab)); }
public void OnSpawned(SpawnerBase spawner, SpawnerCategoryInfo category) { _animator.Play(_hash); }