I want OntrriggerEnter will create GUI

I want when object OntrigerEnter will showGUI button for restartscene and nextscene

bool showGUI;

void OnGUI()
{
    if (showGUI)
    {
        // Restart Scene / Next Scene Code Here
    }
}

void OnTriggerEnter(Collider other)
{
    showGUI = true;
}

void OnTriggerExit(Collider other)
{
    showGUI = false;
}

Just a little something off the top of my head, should work though. Let me know

2 Likes

check a static bool value after reload the scene

1 Like

I put this in restart scene it error " Unity Engine.Rect is a type but is used like variable"
if ( GUI.Button(Rect( 1, Screen.height-25, 75, 25 ), “Restart” )){

Application.LoadLevel( 1 );}

use new Rect()

for example :

if (GUI.Button(new Rect(10, 70, 50, 30), "Restart"))
{
            Application.LoadLevel(1);
}
1 Like

Use the new Unity GUI features. The old features aren’t the best solution for creating GUI with the exception of custom inspectors and editor windows; then you have no choice.

1 Like