Forum rules - please read before posting.

Event for On Pause

Hi Chris

Is there an EventManager event that will fire when the game is paused? That is, I have menus that have Pause Game ticked, and I want to know when that pauses the game for my own script.

Currently I'm checking for the name of the Menu that is being shown, but I'd prefer to just trigger against the game being paused.

I can't see an OnPause, or anything Time related (other than Timers).

Olly

Comments

  • Not in the Event Manager, as pausing the game affects the way ActionLists are played back. However, it is possible through script using the OnEnterGameState event:

    using UnityEngine;
    using AC;
    
    public class PauseGameEvent : MonoBehaviour
    {
    
        void OnEnable () { EventManager.OnEnterGameState += OnEnterGameState; }
        void OnDisable () { EventManager.OnEnterGameState -= OnEnterGameState; }
    
        void OnEnterGameState (GameState gameState)
        {
            if (gameState == GameState.Paused)
            {
                Debug.Log ("Game is paused");
                //
            }
        }
    
    }
    
  • Perfect. Thanks. That'll help no end.

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.