I am creating a menu for a 2d game. I am using simple sprites for the menus and am using arrow keys to navigate it. What I need to happen is, for example, whenever the left arrow key is pressed, a different picture will fill the screen. I was doing this with initiated and destroying objects, but I kept getting errors like, “you can’t destroy something that’s not initiated” or “you cant create whats destroyed already”. Is this the path to go? if so, could I get some example code on how to do it. If I should do it another way, could you show me and give me some example code. Thank You.
try using this, but it uses mouse interaction
var ButtonID : int = 0;
// ID of 1 = Quit button.
// ID of 2 = Sceneloading button
// ID of 3 = Unhides an object
// ID of 4 = hides and object
// ID of 5 = turns off parent, while turning on target(useful for switching between tabs)
var ID2_Scene : String;
var ID_object : GameObject;
var ID5_target : GameObject;
function OnMouseDown(){
if(ButtonID == 1){
Application.Quit();
}
if(ButtonID == 2){
Application.LoadLevel(ID2_Scene);
}
if(ButtonID == 3){
ID_object.SetActive(true);
}
if(ButtonID == 4){
ID_object.SetActive(false);
}
if(ButtonID == 5){
gameObject.SetActive(false);
ID5_target.SetActive(true);
}
}