I am relatively new to scripting and unity. How can i create a dialog box with “Yes” and “No” buttons and display it when a particular objects in unity 3d is clicked ?
Im not sure what you mean by ‘object’. Do you mean a 3d object like a collider in the game world, or a GUI button?
But here
//JS only if you click a physical object
var clicked = false;
function Update()
{
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Input.GetMouseButtonDown(0))
{
if (Physics.Raycast(ray,hit,100))
{
//this is the nane of the object you want to click
if(hit.transform.name == "my object")
{
clicked = true;
}
}
}
function OnGUI()
{
if (clicked)
{
if (GUI.Button(Rect(10,10,30,60),"Yes"))
{
//do stuff
}
if (GUI(Rect(50,10,30,60),"No"))
{
//do stuff
}
}
}
}