using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RandomSpawn : MonoBehaviour
{
public GameObject[] prefabs;
public Vector2 spawnRate;
public List<Vector2> position = new List<Vector2>();
private IEnumerator Start()
{
while (true)
{
yield return new WaitForSeconds(Random.Range(spawnRate.x, spawnRate.y));
var pos = new Vector2(Random.Range(1.9f, -1.9f), Random.Range(3, -3));
if (pos == position)
{
pos = new Vector2(Random.Range(1.9f, -1.9f), Random.Range(3, -3));
}
else
{
position.Add(pos);
}
Instantiate(prefabs[Random.Range(0, prefabs.Length)], pos, Quaternion.identity);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyB : MonoBehaviour
{
void OnMouseDown()
{
Destroy(gameObject);
}
}