Response Menu Panel Custom OnOpen
- PayasoPrince
- Posts: 104
- Joined: Thu Jan 27, 2022 6:47 pm
Re: Response Menu Panel Custom OnOpen
Input Device is set to joystick in Input Device Manager.
You can disregard the second part about the color press, just thought it might be relevant
You can disregard the second part about the color press, just thought it might be relevant
Re: Response Menu Panel Custom OnOpen
What's the current issue then?
- PayasoPrince
- Posts: 104
- Joined: Thu Jan 27, 2022 6:47 pm
Re: Response Menu Panel Custom OnOpen
The current issue is even though I have "Always Auto Focus" ticked, the currentSelectedGameObject is my Fastforward/Continue button in the NPC Panel and not the response button in the first response panel.
Re: Response Menu Panel Custom OnOpen
I just took another look at your code excerpt. That makes sense, since Start() runs only once when the response button is first created. To prevent garbage allocations, the dialogue UI pools response buttons and re-uses them. However, you won't want to use OnEnable() directly because this will run as soon as the button is pulled out of the pool and re-enabled, but before it's selected. Instead, you'll need to wait until the end of the frame. Something like this:
Code: Select all
void OnEnable()
{
StartCoroutine(OnEnableCoroutine());
}
IEnumerator OnEnableCoroutine()
{
yield return new WaitForEndOfFrame();
if (EventSystem.current.currentSelectedGameObject)
{
...
}
}
- PayasoPrince
- Posts: 104
- Joined: Thu Jan 27, 2022 6:47 pm
Re: Response Menu Panel Custom OnOpen
Just tried your change. Progress?
currentSelectedGameObject is now my Continue Button. It was previously the FastForward Button.
Still not quite there yet...
currentSelectedGameObject is now my Continue Button. It was previously the FastForward Button.
Still not quite there yet...
Re: Response Menu Panel Custom OnOpen
I'm still not clear on what your intent is, but you could make it wait until the next frame by changing the yield line to:
Code: Select all
yield return null;
- PayasoPrince
- Posts: 104
- Joined: Thu Jan 27, 2022 6:47 pm
Re: Response Menu Panel Custom OnOpen
All I wanted to do was create my own cursor (like an arrow), that get's created next to the first highlighted response button.
This did it! CurrentSelected is now the highlighted response.Tony Li wrote: ↑Sat Apr 30, 2022 10:28 pm you could make it wait until the next frame by changing the yield line to:Code: Select all
yield return null;
From there, I added:
Code: Select all
public void Update()
{
if(choiceSelector != null)
{
choiceSelector.transform.position = new Vector3(transform.position.x, EventSystem.current.currentSelectedGameObject.transform.position.y - 30, transform.position.z);
}
}
Re: Response Menu Panel Custom OnOpen
Great! I'm glad you got it working the way you want.