This commit is contained in:
CortexCore
2024-11-13 17:47:45 +08:00
parent c4af12acd7
commit 416e3322db
208 changed files with 2591757 additions and 1497 deletions

View File

@@ -0,0 +1,47 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace NGS.AdvancedCullingSystem.Tutorial
{
public class Spawner : MonoBehaviour
{
[SerializeField]
private GameObject _prefab;
[SerializeField]
private int _maxInstances = 2000;
[SerializeField]
private float _delay = 0.02f;
private int _counter;
private float _timer;
private void Update()
{
_timer += Time.deltaTime;
if (_timer > _delay)
{
Spawn();
_timer = 0;
_counter++;
if (_counter > _maxInstances)
enabled = false;
}
}
private void Spawn()
{
GameObject instance = Instantiate(_prefab);
instance.transform.position = transform.position;
instance.transform.rotation = Random.rotation;
instance.transform.localScale = Vector3.one * Random.Range(1, 2.5f);
}
}
}