I can already give guitext value, but I want it to turn out to be a button and you can change the values within the array.
I’m going to help them?
#pragma strict
var testGUI : GameObject;
var testGUI_1:GameObject;
var testGUI_2:GameObject;
var r:int;
var i:int;
var j:int;
var arr = new Array();
arr.length = 19;
function Start () {
testGUI = GameObject.Find("Squared");
testGUI_1 = GameObject.Find("Squared_1");
testGUI_2 = GameObject.Find("Squared_2");
testGUI_3 = GameObject.Find("Squared_3");
}
function Update () {
}
public function random_array(){
for(i = 1;i<10;i++){
r = Random.Range(1,20);
// Debug.Log("Run1");
for(j = 1; j < i;j++){
if(arr[j] == r ){
r = Random.Range(1,20);
// Debug.Log("Run2");
}
}
arr[i] = r;
// Debug.Log("Random : "+r);
}
showRandom();
}
function OnGUI (){
if(GUI.Button(Rect(450,500,70,70),"Random")){
random_array();
}
}
//show GUI
function showRandom() {
// Debug.Log(arr[1]);
testGUI.guiText.text = arr[1].ToString();
testGUI_1.guiText.text = arr[2].ToString();
testGUI_2.guiText.text = arr[3].ToString();
}