Forum rules - please read before posting.

Changing MenuElement visibility

Hi there,

I have a Menu with a few MenuElements, which are buttons and are linked to Unity UI buttons themselves. I have those set to "When invisible, disable interactability".

I have a script that toggles MenuElement.IsVisible of each of those buttons. I've checked that the visibility of my menu elements is correct on the "Menu" tab of the AC Game Editor. However, my UI buttons are not changing state until the next time I run my scene, which is really odd. So:

  1. Run scene, script turns all elements off & turns elements 1 & 2 on. Nothing happens
  2. Stop scene, run it again, script turns all elements off & turns elements 3 & 4 on. I see that the UI buttons that are turned on are 1 & 2
  3. Stop scene, run it again, script turns random elements off and on. I see that UI buttons 3 & 4 are on.

I've tried refreshing the menu with Recalculate() & ResetVisibleElements() but this doesn't seem to do anything at all, and I'm at a bit of a loss here. I also don't understand why things are being cached between runs.

I'm running Unity 2019.4.2f1 & AC 1.70.2

Thanks in advance!

Comments

  • It sounds like you're affecting the Menus as stored in the Menu Manager, rather than the runtime copies in PlayerMenus.

    Access your Menus using PlayerMenus.GetMenus or PlayerMenus.GetMenuWithName, rather than kickStarter.menuManager. If you need specific help with your script, share it here and I'll amend it for you.

  • You are of course completely right :). I was reading it directly, and I do something similar to global variables, so I guess I should avoid the managers?

    Thanks in any case, very helpful as usual!

  • I do something similar to global variables, so I guess I should avoid the managers?

    Changes made to Manager values will be retained once you exit Play Mode. Similarly in the case of Global Variables, you can access their runtime equivalents with AC.GlobalVariables.

    See the "Menu scripting" and "Variable scripting" chapters of the Manual for more details on accessing these through script.

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.