Triggering UIActiveStateUpdater via external script


(Maylin Liaran) #1

Hello.
I have a button, which should NOT be active when the game is paused. It works fine with UIActiveStateUpdater + graph + HasActiveSession, cool.

BUT, due to Menu UI animation logic I made I sometimes need to, via my external script, disable this button with setActive(false).

When the time comes to do setActive(true) the button appears as normall (the game is still paused btw). But I expected UIActiveStateUpdater to check for the game state and disable it again, and I assume it wasn’t triggered to do so.

So my question is how to ask (trigger) it to check game state via external script, if the component has already been attached to the object via Editor.


(Leslie Young) #2

It will only trigger when the state changes on whatever is checked. So if you manually disable the object then it can’t enable itself again if the state change already occurred on the watched item(s).

You can try doing the following to trigger the refresh since you are watching the active state.

GameGlobal.Instance.GameSessionActive.Value = !GameGlobal.Instance.GameSessionActive.Value;
// do it a second time to restore original state
GameGlobal.Instance.GameSessionActive.Value = !GameGlobal.Instance.GameSessionActive.Value;

I’ll add a method ForceUpdate() by which one can force UI Updaters to do checks for the next patch.


(Maylin Liaran) #3

Thank you very much