Forum rules - please read before posting.

Change Intractability of menu when paused

edited October 8 in Technical Q&A

Hi

My game has several UnityUI "In Game" menus that I always want visible, but not necessarily interactable.
Their appear type is "Manual". They do not pause the game. They are not clickable in cutscenes.

I would like to disable the intractability of the menus elements (but not make hide them) under certain conditions - for example when the game is paused.

Its late here, but this quick test seems to work fine:

  • Hook into the OnEnterGameState event to know if the game is paused or unpaused.
  • Find my menu by name, ensure its on.
    -- Iterate over menu elements and SetUIInteractableState depending on game state

Is this the correct way to handle this? Is there a better/suggested way?

Thanks

Comments

  • This might be OK - but AC will call this function itself via its own event hook. You would need to ensure your script has a larger DefaultExecutionOrder.

    Rather than iterating over all elements/objects, however, it's easier to just affect a Canvas Group component that's a shared parent to your interactive objects. You can then set its Interactable state to affect them all - and avoid any conflict with AC.

  • Hi
    Thanks.
    I wanted to make sure there wasn't a existing AC way to do this, and good point on the execution order.
    Agreed - the canvas group works as well as it keeps AC separate
    Thanks

  • Note: One downside to this is AC still fires the click event when the Alternate Input Button is pressed - AC thinks the button is interactable (as technically is).

    I'll add an additional check in my click callback to ensure the CG is also interacable, but it does mean we bypass the unity interactable flag.

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.