Forum rules - please read before posting.

Stop Menu from working during Cutscene

edited June 2020 in Technical Q&A

I created a couple of menus that are working well. However they can be turned on during a cutscene and I dont want that to happen.

How do i stop that from happening?

I'm using a unity ui with input key appear type.

Comments

  • When a Menu is locked, it will not turn on even if it's "Appear type" condition is met. The Menu: Change state Action can be used to lock/unlock a Menu, but you can also do this through scripting:

    using UnityEngine;
    using AC;
    
    public class LockMenuInCutscene : MonoBehaviour
    {
    
        public string menuName = "MyMenu";
    
        private void OnEnable () { EventManager.OnEnterGameState += EnterGameState; }
    
        private void OnDisable () { EventManager.OnEnterGameState -= EnterGameState; }
    
        private void EnterGameState (GameState _gameState)
        {
            if (_gameState == GameState.Cutscene) PlayerMenus.GetMenuWithName (menuName).isLocked = true;
            if (_gameState == GameState.Normal) PlayerMenus.GetMenuWithName (menuName).isLocked = false;
        }
    
    }
    

    However, the better way is to set the Menu's "Appear type" instead to "Manual", and then rely on Active Inputs to control its state.

    When set to Manual, the Menu will only turn on/off due to scripting or Menu: Change state Actions, and Active Inputs let you run such Actions when an input key is pressed.

    Active Inputs are a way of running ActionLists when an input key is pressed, and they can also be limited by game state (i.e. normal gameplay, cutscene, etc). For more, see the Manual's "Active inputs" chapter.

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.