- Home /
Help with GUI popup
I have a script attached to game objects on the scene, Is there any way to add a function that destroys the game objects if the player clicks Yes on the GUI popup and close the GUI popup if the player clicks No. Also how can i add the Yes and No button to the GUI popup. Help please.
My script:
using UnityEngine; using System.Collections;
public class OnClick : MonoBehaviour {
// Use this for initialization
private bool PopUp;
public string Info;
void OnMouseDown()
{
PopUp = true;
}
void DrawInfo()
{
Rect rect = new Rect (20,20, 300, 200);
Rect close = new Rect (300,20,20,20);
if (PopUp)
{
GUI.Box(rect, Info);
if (GUI.Button(close,"X"))
{
PopUp = false;
}
}
}
void OnGUI()
{
DrawInfo();
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613172129im_/https://answers.unity.com/themes/thub/images/avi.jpg)