Forum rules - please read before posting.

Resetting Unity UI Interactable Setting

Hey Chris, another minor issue I've come across. I've took it as far as I can and I think I know exactly what is happening however how best to fix it I am unsure of.

I have an in game tablet for the player to use and in certain situations I need to disable certain buttons to prevent the player from screwing up some of the logic (and for tutorial sections). I've got this working perfectly with custom scripts changing the Interactable bool value of the relevant UI buttons. The problem is when the gamestate changes the interactable values reset to being true when normal gamestate is entered. I can understand why this happens, I imagine it is a way to ensure that the player can't interact with gameplay menus either during cutscenes or when the game is paused.

So after a lot of digging I eventually came to the solution of creating a custom script to listen for OnEnterGameState and then checking if entering back to a normal state and then checking if I have made changes to UI (done so by checking if a custom bool is true or not) and if so then I reinstate the interactability value of the relevant UI. This didn't work for some reason despite my Debug.Log messages stating otherwise. After more investigation I now realise that the changes are indeed being made however despite the gamestate being changed back to normal at the time I am making these changes I don't believe AC is fully finished with all the actions it runs through when reinstating the game back to normal and so my reinstated changes are overwritten by AC as it finishes up it's function of returning everything back to normal (including then making all active UI buttons interactable).

I believe I could simply call my function as a coroutine and simply wait for some time (0.1 seconds) before making the changes to ensure it is the last thing called however I'd obviously prefer to know exactly when AC is fully finished with all it's gamestate change actions and then call my function but I'm struggling to find this out. Is there a way to do this?

I realise that hiding the element via the Menu Manager would work as it would keep the changes made however hiding the elements is not practical as I need them visible but not interactable. As ever thanks again in advance.


  • How and when AC will update the "Interactable" state of an element is down to properties of both the element and the menu it's within. You'd need to share those details for me to know what's going on.

    What you could try instead, however, is insert a new child object in between the RectTransform and the Button in question, and then attach a Canvas Group component to it. This comes with its own Interactable checkbox that will override its children, so you can control this instead. So long as you don't connect this object up to the Menu Manager, AC won't control it.

  • Ah! So simple - thanks Chris.

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.