Hi Tony,
I'm looking to make a selection menu within a conversation easier to navigate and I wanted to ask a couple of quick questions. Here's what it looks like:
By default the top option is highlighted whenever navigating to a selection of conversation options. Is there a simple way to choose which option is highlighted instead? That way if the player picked to add a Cucumber, it would be automatically highlighted next time round and reduce the amount of navigation required.
My other question was if it's possible to set up the Response Button Template in Dialogue UI to wrap around a 'down' input back to the top of the responses? So on the image above I would be able to press down on 'Sweetcorn' and 'Lettuce' would be highlighted. In the template it's currently set to automatic navigation, but I'm not sure how to get the wrap around set up when the buttons are being created dynamically.
Cheers,
Rob
Conversation Option Navigation
Re: Conversation Option Navigation
Hi Rob,
You can do it with a bit of scripting. Make a subclass of StandardUIMenuPanel and replace the component on your dialogue UI's menu panel. Override Update() and ShowResponses(). Something like:rykaan wrote: ↑Mon Mar 29, 2021 6:45 amBy default the top option is highlighted whenever navigating to a selection of conversation options. Is there a simple way to choose which option is highlighted instead? That way if the player picked to add a Cucumber, it would be automatically highlighted next time round and reduce the amount of navigation required.
Code: Select all
public class MyMenuPanel : StandardUIMenuPanel
{
private int lastSelectedButtonIndex;
// Record the current menu position:
protected override void Update()
{
base.Update();
var index = instantiatedButtons.IndexOf(EventSystem.current.currentSelectedGameObject);
if (index != -1) lastSelectedButtonIndex = index;
}
// When showing new menu, try to set selection to
public override void ShowResponses(Subtitle subtitle, Response[] responses, Transform target)
{
base.ShowResponses(subtitle, responses, target);
if (0 <= lastSelectedButtonIndex && lastSelectedButtonIndex < instantiatedButtons.Count)
{
UITools.Select(instantiatedButtons[lastSelectedButtonIndex].GetComponent<UnityEngine.UI.Button>());
}
}
}
Inspect your response menu's StandardUIMenuPanel component. Tick 'Loop Explicit Navigation':rykaan wrote: ↑Mon Mar 29, 2021 6:45 amMy other question was if it's possible to set up the Response Button Template in Dialogue UI to wrap around a 'down' input back to the top of the responses? So on the image above I would be able to press down on 'Sweetcorn' and 'Lettuce' would be highlighted. In the template it's currently set to automatic navigation, but I'm not sure how to get the wrap around set up when the buttons are being created dynamically.
Re: Conversation Option Navigation
Excellent response as always Tony.
I hooked up your suggested code to a LUA function that I can call from within conversations, so now I can selectively turn it on and off for specific looping questions. I also ticked the box, good stuff.
Cheers a bunch!
Rob
I hooked up your suggested code to a LUA function that I can call from within conversations, so now I can selectively turn it on and off for specific looping questions. I also ticked the box, good stuff.
Cheers a bunch!
Rob
Re: Conversation Option Navigation
Good thinking - the Lua function will be handy!