Forum rules - please read before posting.

Access Pause button via script

edited June 2014 in Technical Q&A
I'm trying to use a script to make an action when I click on the pause button...the script is like this

void update ()
{
if (Input.GetKeyUp(KeyCode.Space))
{
 myEffect.enabled =!myLight.enabled;
}}}

what should I put instead input getkeyup to have this working when I'm on the pause button?

thx

Comments

  • or even better something like : if the engine is paused do this
  • I don't understand what you mean - what pause button?

    The code looks OK, but bear in mind that if the game is paused you'll need to have it in an Update function, not a FixedUpdate function, to work.
  • I'll try ti explain better. I need to call a camera effect only when the game is paused. How would you di that?
  • Checking the value of the StateHandler script's "gameState" variable will tell you if it's paused or not:

    StateHandler stateHandler = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>();
    if (stateHandler.gameState == GameState.Paused)
    {
      // The game is paused
    }

  • edited June 2014
    he keeps sayng the name StateHandler doesn't exist in current context.

    Maybe at the moment the boolean is private? (no is not just cheched)...
  • At the moment my script is like this:

    Public class BlurOn : MonoBehaviour
    {
         private BlurEffect myBlur;

         void Start ()
         {
          myBlur = GetComponent<BlurEffect>();
          }

          void Update ()
          {
          if ??????????????????
          {
          myBlur.enabled = !myBlur.enabled;
          }
          }
          }
      

    the ?????????? is the part I'm missing...







  • I solved like this Chris...just tell me honestly what u think about it.

    I assigned a constant id to the main camera. then I did a script with void TurnOnEffect and void TurnOffEffect attached to the maincamera. Then I went into the menu manager and in the pause menu I added on the base action list ( the deselect inventory one) another actions (send object message custom turn on effect)...now it works...but I don't know if this was the right way to achieve what I was looking for.
  • If it works, it works!  Personally, I'd write code in the MenuSystem script instead, but that's still a viable way.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.