Hi All,
I have any problem when i try to instantiate a game object using array…
This is my script :
using UnityEngine;
using System.Collections;
public class GUI_Array : MonoBehaviour {
// masukkan objek tanda taktis
public GameObject ANG;
public GameObject ARHANUD;
public GameObject ARMED;
public GameObject HUB;
public GameObject INF;
public GameObject KAV;
public GameObject KES;
public GameObject PAL;
public GameObject PNB;
public GameObject POM;
public GameObject ZI;
//
public Transform Kotak; // memasukkan cube sebagai posisi awal yang di load
public Rect windowRect = new Rect(20, 20, 120, 50); //membuat layar windows GUI
string[] buttonName =new string[11] {"ANG","ARHANUD","ARMED","HUB","INF","KAV","KES","PAL","PNB","POM","ZI"}; // Array dengan type data string
void OnGUI ()
{
windowRect = GUILayout.Window(0, windowRect, textButton, "Membuat Skenario", GUILayout.Width(200));
}
void textButton(int winID){
for(int i = 0; i<11; i++) //perulangan untuk menambah tombol sebanyak index pada array
{
if(GUILayout.Button(buttonName[i])){
print("I pressed " + buttonName[i]);
//Instantiate(ANG, Kotak.position, Kotak.rotation); // --> This is just one of game object can be instantiate with every button
}
}
}
}
How can to solved it…Thank’s before…