Search code examples
c#unity-game-engineaugmented-realityvuforia

How to show a modal window after button click in Unity?


I am new to Unity and C# programming. I just want to know how to open a modal window on button click.

public class Buttonwindow: MonoBehaviour 
{
    public void clicked(Button button)
    {
        Debug.Log("Button click!");

    }
}

What code will be going in here to show a pop up window? Thanks!


Solution

  • Use yourModelWindowPanel.SetActive(true) to enable/show your Window and pass in false to the SetActive function to hide it. This could be a panel with UI components under it.

    public class Buttonwindow: MonoBehaviour 
    {
        public GameObject modalWindow;
        public void clicked(Button button)
        {
            Debug.Log("Button click!");
            modalWindow.SetActive(true);
        }
    }