Hiya everyone!
I have my conversation menu set up to auto highlight the first option upon opening the menu. This works great, but I only want this behavior when the player is using the Controller and Keyboard input option. (I allow the user to switch between controller and keyboard at will). Can I get some help making sure the auto highlight option only works if the player is using a Controller, but not when using the mouse? Im not a programmer so wtiting the code for this myself is not something I can do.
Comments
Here's a custom Action to check the game's current input method:
This action works great for detecting the current method, but I could also just use my assigned global variable for that. What I cant seem to do is toggle the Auto Select First Visible Element.
I have this set globally in the menu properties. Ive tried un-checking this option and instead using an action list when the menu turns on to set the auto select nature, but when I try to use an actionlist, it ignores any auto select first visible element command whether it's in the action list or the menu properties itself.
Using Source: Unity UI Prefab
Currently using Unity 2018.2.17f1
AC: v1.67.4
Changes to a Menu's properties in the Menu Manager at runtime won't be reflected until the game is restarted, but you can access the "live" instances of them through script.
Right-click the Auto-select first visible Element? field to get an API reference to it. Something in the form of:
You can set this to true/false to change it at runtime, but doing so in an "ActionList when turn on" is likely too late. Set it instead at the same time that you change the input method / global variable.
Im very sorry for my ignorance, but I don't know what to do with this bit of code.
Right clicking on the field game me this result (As you stated):
AC.PlayerMenus.GetMenuWithName ("Conversation").autoSelectFirstVisibleElement
But I don't know what to do with this.
When the player starts the game, they choose an input method via custom action script. I Also set the global varaibe (IsUsingJoystick) via actionscript at that time.
You'll want to use it whenever you change the input method:
You should also run it when the game begins even if this choice is not given, so that it's always set to the correct value - as it'll be reset when the game is launched.
Hi,
you could turn this code into a custom action based on the tutorial.
But the simplest implementation would probably be creating a custom script and then use the Object: Call event action.
You would create and empty object in your scene, put the script on it and then drag and drop the object in the Call event action and select the "UpdateMenu" method. You can pass the name of the menu as a parameter.
Yes, indeed. Going further, you can also make this new GameObject a prefab, and then just reference the prefab itself with the Object: Call event Action. There's no need in this instance for it to be actually present in the scene itself.
Thank you both so much for the help! This is working great now!