- Home /
Question by
Zekt · Jun 11, 2013 at 05:16 PM ·
gameobjectarraybuttons
Making a button from a list of arrays.
Hi Unity Answers community,
I basically want to make a button for each GameObject in my arrays, the script I have ATM is:
var buttons : GameObject[];
private var randNumber: int;
function Start () {
for (var i = 0; i < buttons.Length; i++)
buttons[i].SetActive(false);
InvokeRepeating("SwitchButtons", 0.0, 5.0);
}
function SwitchButtons() {
for (var i = 0; i < buttons.Length; i++)
buttons[i].SetActive(false);
randNumber = Random.Range(0,buttons.Length);
buttons[randNumber].SetActive(true);
}
How would I do that?
Comment
You can make the objects in your array clickable (fairly easy), or you can use other game objects that overlay these that are clickable (not as easy but not too bad), or you can make GUI buttons that overlay the objects (more difficult). Do you know what you want to do?
Your answer
Follow this Question
Related Questions
how to check for GameObject is null in array with random 1 Answer
Use an objects (from array) position to focus a camera on 3 Answers
Cannot convert 'UnityEngine.Collider[]' to 'UnityEngine.gameObject[]' using OverlapSphere 3 Answers
Detection if a GameObject is below you or next to you? 1 Answer
Need help with an array. - C# 3 Answers