コード例 #1
0
        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());
        }
コード例 #2
0
        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
        }
コード例 #3
0
        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));
        }
コード例 #4
0
 public void DestroyObject(SpawnerBase spawner, SpawnerCategoryInfo category, GameObject obj)
 {
     _pools[category].Destroy(obj);
 }
コード例 #5
0
 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
 }
コード例 #6
0
 public GameObject GetObject(SpawnerBase spawner, SpawnerCategoryInfo category)
 {
     return(UnityEngine.Object.Instantiate <GameObject>(category.prefab));
 }
コード例 #7
0
 public void OnSpawned(SpawnerBase spawner, SpawnerCategoryInfo category)
 {
     _animator.Play(_hash);
 }