To make my question more clear, I want it so that when you click the button in the middle of the screen, a picture comes up, then every time you click it a different picture comes up,at a random location on the screen. I’m clueless of where to go about this, any ideas?
You just need something like that bro:
public Texture2D picture1;
void OnGUI(){
if(GUI.Button(new rect(50,50,50,50), "Click me!")){
GUI.DrawTexture(new rect(Random.Range(min,max), Random.Range(min,max), 50, 50), picture1);
}
}
I feel like this would work, however it hasn’t been tested.
using UnityEngine;
using System.Collections;
public class Swap : MonoBehavior
{
public GameObject[] objects;
private int currentObject = 0;
private Random random = new Random();
private void Start()
{
for(GameObject i in objects)
{
Instantiate(i, new Vector(0,0,0), i.transform.rotation);
i.SetActive(false);
}
}
private void Update()
{
if(Input.GetKeyDown(KeyCode.E))
{
currentObject = random.Next(0, objects.Length - 1);
objects[currentObject].SetActive(true);
}
}
}