Page 1 of 1

How to reset EventSystem during fade out on conversation end?

Posted: Wed Mar 15, 2023 6:05 am
by VironGameDev
Hi,

I have an issue when at the end of a conversation with the EventSystem. The situation is the following:

In the EventSystem the "Current Selected" is a button and I start a dialogue. The EventSystem is now used by the DialogueSystem which is fine of course. At the end of the dialogue the Dialogue UI is fading out and after the fade out the button is selected again.

What I want to achieve is that the initially selected button is already selected again during the fading out. Any ideas how I can do this?

Re: How to reset EventSystem during fade out on conversation end?

Posted: Wed Mar 15, 2023 8:55 am
by Tony Li
Hi,

Two things to try:

1. Inspect your dialogue UI's dialogue panel and subtitle/menu panels. Tick Select Previous On Disable.

2. If that doesn't address the issue, add a script to the Dialogue Manager GameObject that has OnConversationStart and OnConversationEnd special script methods. Something like:

Code: Select all

using UnityEngine;
using UnityEngine.EventSystems;
public class SelectPreviousOnConversationEnd : MonoBehaviour
{
    private GameObject previous;
    void OnConversationStart(Transform actor) { previous = EventSystem.current.currentSelectedGameObject; }
    void OnConversationEnd(Transform actor) { EventSystem.current.SetCurrentSelectedGameObject(previous); }
}

Re: How to reset EventSystem during fade out on conversation end?

Posted: Mon Mar 20, 2023 3:14 am
by VironGameDev
Hi Tony, thanks a lot!

I already had the box "Select Previous On Disable" ticked. But I did use your second suggestion and managed to get it done. Thanks again!

Re: How to reset EventSystem during fade out on conversation end?

Posted: Mon Mar 20, 2023 8:45 am
by Tony Li
Glad to help!