using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectSpawner : MonoBehaviour
{
public GameObject[] ObjectID = new GameObject[3];
public GameObject[] goCube = new GameObject[sizeArrayCube];
public GameObject[] goSphere = new GameObject[sizeArraySphere];
public GameObject[] goCylinder = new GameObject[sizeArrayCylinder];
public Camera camera;
public int OBJ;
public static int sizeArrayCube = 0;
public static int sizeArraySphere = 0;
public static int sizeArrayCylinder = 0;
// События для кнопок
public void SpawnCube()
{
OBJ = 0;
}
public void SpawnSphere()
{
OBJ = 1;
}
public void SpawnCylinder()
{
OBJ = 2;
}
public void ObjSpawner()
{
if (Input.GetMouseButtonDown(0))
{
Instantiate(ObjectID[OBJ], camera.ScreenToWorldPoint(Input.mousePosition) + Vector3.forward, Quaternion.identity);
if(OBJ == 0)
{
sizeArrayCube++;
goCube[sizeArrayCube] = ObjectID[OBJ];
}
else if(OBJ == 1)
{
sizeArraySphere++;
goSphere[sizeArraySphere] = ObjectID[OBJ];
}
else if(OBJ == 2)
{
sizeArrayCylinder++;
goCylinder[sizeArrayCylinder] = ObjectID[OBJ];
}
}
}
void Update()
{
ObjSpawner();
}
}
public List<GameObject> goCube = new List<GameObject>();
var CreatedObject = Instantiate(...);