Ok what i am trying to do is set it up so i can click a character then when it is clicked 2 GUI buttons pop up and ask Confirm or Go Back. The problem i am having is when you click you can click over and over again making more Gui buttons pop up. please help... heres the code: Oh yea i also want to make it so i cant click another Character while you have one clicked (There are 4 characters). Ive tried adding if statements before the buttons are created but it results in still being able to click a different character and an error that states that "GUI functions can only be called from OnGUI". Please tell me if there is a better way of going about this... :D
Script 1
var startlook : Transform;
var clickeffect : Transform;
static var clickedclass : Transform;
//Look at target
function OnMouseOver () {
Test2.targ = transform;
}
// Look away from target
function OnMouseExit () {
Test2.targ = startlook;
isover = false;
}
function OnMouseUp () {
clickedclass = transform;
OnGUI();
// This controls the special effect for when you click
var clickedeffect = Instantiate(clickeffect,transform.position,transform.rotation);
Debug.Log("Clicked");
}
// Gui controls
function OnGUI () {
// if a class is clicked ask if you want to confirm or deny
if(GUI.Button(Rect(10,10,60,60),"Confirm")){
Debug.Log("Clicked Confirmed");
}
if(GUI.Button(Rect(10,70,60,60),"Go Back")){
Debug.Log("Clicked Go Back");
}
}
Script 2
static var targ : Transform;
function Update () {
//Makes what ever this script is attached to look at the target assigned
transform.LookAt(targ);
}