Hey everybody,
hey Chris!
I'm trying to change menu properties at runtime whenever another input device is activated, but somehow the change doesn't take.
protected void SetMenuPositionType(string menuName, AC_PositionType type)
{
Menu menu = AC.KickStarter.menuManager.GetMenuWithName(menuName);
menu.positionType = type;
}
The method is called with the correct parameter, but the position type of the menu hasn't changed after calling this method.
Should this work and the problem is somewhere else?
Thanks!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
At runtime, Menu data is transferred from the Menu Manager asset file to the PlayerMenus script. Your code is affecting the original Menus, not their runtime instances.
Getting the Menu via PlayerMenus should do it:
Thank you @ChrisIceBox for the quick response! I understand now, but for some reason it still doesn't work. A simplification of my code:
I also tried directly setting it in the event function:
It's weird because it finds the menu and sets the correct value, but it doesn't behave like it should. Maybe I'm setting it "too late", because the menu has already been instantiated? If so, at what point can I set the position type so that the menu behaves correctly?
It seems to work when instead of AC_PositionType and positionType I use UIPositionType and uiPositionType.
It's based on your Menu's Source, as AC menus have slightly different Position Type values to Unity UI ones.
If your Menu uses Adventue Creator as its Source, use positionType. Otherwise, use uiPositionType.
It's worth mentioning, though, that the other way to tackle this kind of situation is to duplicate your Menu, make adjustments to it as necessary, and then keep one locked at all times - locking/unlocking as a pair when needed.
Thank you very much for the explanation and the recommendation! I will think about this approach.