How to reset EventSystem during fade out on conversation end?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
VironGameDev
Posts: 7
Joined: Wed Mar 15, 2023 5:42 am

How to reset EventSystem during fade out on conversation end?

Post 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?
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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); }
}
VironGameDev
Posts: 7
Joined: Wed Mar 15, 2023 5:42 am

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

Post 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!
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Glad to help!
Post Reply