InGame Menu (toggle)

Hey guys, using C# to make an ingame Menu which’ll toggle on and off.

Using the blur screen Image effect for once I hit escape and too disable once Escape is pressed again.

here is my script;

using UnityEngine;

using System.Collections;

public class IngameMenu : MonoBehaviour
{
bool paused = false;

void Update()
{
    if (Input.GetKeyDown(KeyCode.Escape))
        togglePause();
}

void OnGUI()
{
    //boop
}

void togglePause()
{
    if (paused)
    {
        Time.timeScale = 1f;
        paused = false;
    }
    else
    {
        Time.timeScale = 0f;
        paused = true;
    }
}

}

I was wondering if it were possible to actually disable/enable to script or communicate to it via the code, I’m not too sure how to do it.

Ok, I know how to do this in JS and I suspect its the same for C#

All you would need is create a static function. So it could be something like:

var stat: boolean = true; // default enabled

static function disableTogglePause( in)
{
stat =in;
}

void togglePause()
{
if(stat)
 {
 // whatever you used to do.
 }

}

You can call this anywhere in the code by using the class name and the method. ie

 myClassname.disableTogglePause(false);

It looks sort of the same, but I don’t really understand JavaScript.