I am trying to use ui buttons to invoke clones of a prefab to spawn in. I have it so that on my UI panel is a scroll view with different buttons. I also have a camera and “spawner” location so that when a button is pressed the object will pop up in the spawn area to give a preview. i have about 30 different object that i placed in my element area. I just dont know how to link the buttons to the code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class spawner : MonoBehaviour
{
public Transform[] spawnLocations;
public GameObject[] whatToSpawnPrefab;
public GameObject[] whatToSpawnClone;
void update(){
spawnhere();
}
void spawnhere(){
whatToSpawnClone[0] = Instantiate(whatToSpawnPrefab[0], spawnLocations[0].transform.position, Quaternion.Euler(0,0,0)) as GameObject;
}
}