I want a java code that when click to an object in the game appear buttons Help!!!
var btnTexture : Texture;
function OnMouseDown(){
function OnGUI() {
if (Input.GetMouseButtonDown(1)){
if (!btnTexture) {
Debug.LogError(“Please assign a texture on the inspector”);
return;
}
if (GUI.Button(Rect(10,10,50,50),btnTexture))
Debug.Log(“Clicked the button with an image”);
if (GUI.Button(Rect(10,70,50,30),“Click”))
Debug.Log(“Clicked the button with text”);
}
}
}
var btnTexture : Texture;
var showButton : bool;
function OnMouseDown(){
showButton = true;
}
function OnGUI() {
if (showButton)
{
if (!btnTexture) {
Debug.LogError("Please assign a texture on the inspector");
return;
}
if (GUI.Button(Rect(10,10,50,50), btnTexture))
Debug.Log("Clicked the button with an image");
if (GUI.Button(Rect(10,70,50,30),"Click"))
Debug.Log("Clicked the button with text");
}
}
When you will click on this GameObject showButton variable will set true and button will be drawn in OnGUI cycle.
I seem to have screwed something up adapting this… THe idea is for an “exit” button to appear with the hidden object, i.e. rendering at the same time. Any help?