- Home /
 
How to create a dialogue box and display it when an object in clicked in unity 3d ?
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 ?
               Comment
              
 
               
              Answer by BloodBTF · Jul 18, 2016 at 02:13 AM
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
     }
     }
     }
     }
 
 
              Your answer
 
             Follow this Question
Related Questions
How do i Extrude a 2D mesh(or Model) from one point to another? 1 Answer
How to get a dialog box on selecting a 3d object ? 0 Answers
Distribute terrain in zones 3 Answers
How do i Achieve mesh Extrusion? 2 Answers
How to reduce object materials ? 1 Answer