Page 1 of 1

First response deselected on dialogue start

Posted: Tue Dec 10, 2024 11:58 am
by Maltakreuz
I have just updated dialogue sys from 2.2.9 to 2.2.50 in my project. It went surprisingly smooth. But one minor problem is arised. If I start first conversation first response was always automatically selected in dialogue, what is pretty convinient. It is not the case anymore after update. As I remember this automatically selection of first response was not my custom code, but just ootb feature of Dialogue Sys. I have found several hints what is going on:

1) Technically first response will be selected for very short time, I can even see it is blinking shortly, but then instantly deselected back.
2) It only happens on first dialogue. Further dialogues have Response 1 correctly selected from start. ( I have tried pre-warm option in main setting, but it does not seems to help here)
3) I can still hear my custom Click sound by hitting enter without selection. I have debugged with EventSystem.current.currentSelectedGameObject to see what object has selection then instead. And result is a pretty big hint. It is Response Button Template, so the template button that will be used to produce all other reponses. (If this matters, I am using slighly adjusted version of Runic Standard Dialogue UI).

Any ideas or workarounds for that? Maybe this is some known bug, or my wrong configuration. I would say before update this was not the case. What class in Dialogue sys is responsible for first selection at all?

Of course I could try quick and dirty bugfix like:

Code: Select all


void Update() {
    if (EventSystem.current.currentSelectedGameObject.name == "Response Button Template") {
      somehow_select_response_1();
      // I think just this will not work
      // EventSystem.current.setCurrentSelectedGameObject(FindObjectByName("Response 1"));
    }
}
But it is pretty messy bugfix try, so I have decided to ask first.

Re: First response deselected on dialogue start

Posted: Tue Dec 10, 2024 3:44 pm
by Tony Li
Hi,

Make sure your Dialogue Manager GameObject's Input Device Manager component > Always Auto Focus checkbox is ticked. It probably is.

Then inspect your dialogue UI's response menu panel. Make sure Focus Check Frequency and Refresh Selectables Frequency are non-zero (e.g., 0.1 and 0.5).

If that doesn't help, keep an inspector view on the EventSystem GameObject while playing. The bottom of the EventSystem inspector will show what button is currently selected (focused). When the first response menu appears and the first response button becomes deselected, let me know what the EventSystem thinks is currently selected.

You may also want to add DeselectPreviousOnPointerEnter components to your response menu button(s). This won't fix the problem, but the example dialogue UI prefabs that shipped with 2.2.9 didn't have this component on them. It makes selection look better when using the mouse.

Re: First response deselected on dialogue start

Posted: Wed Dec 11, 2024 4:49 pm
by Maltakreuz
1) Hi, thank you for quick response. And sorry for blaming DialogueSys, I have just forgotten that I have one more customization of it :) So EventSystem inspector have shown me that it is Response Button Template will be selected as I have own list to support joystick etc. My code relied that this object should be disabled and just used this:

Code: Select all

responseButtons.Clear();
foreach (Transform button in transform) {
    if (button.gameObject.activeSelf) {
        responseButtons.Add(button.GetComponent<Button>());
    }
}
I have just added some name check and everything works as before

Code: Select all

responseButtons.Clear();
foreach (Transform button in transform) {
    if (button.gameObject.activeSelf && button.gameObject.name != "Response Button Template") {
        responseButtons.Add(button.GetComponent<Button>());
    }
}
Probably just Script Order changed for some reason and my custom code now was executed before template response was disabled. Anyways it works with this change just as it worked in 2.2.9


2) DeselectPreviousOnPointerEnter works nicely and indeed fixes one possible bug that was present in my setup: it was possible to have two options selected at same time, if moving mouse after up/down selection. No mouse selection deselects previous. Great point, thank you.

-------------

3) Another small question to avoid makng microthreads: After update I have some Null Pointer Exception in CharacterInfo.RegisterActorTransform(...). As I can see in git changes some code was added in the end of method:

Code: Select all

public static void RegisterActorTransform(string actorName, Transform actorTransform)
{
...
+   // Also update active conversations' caches:
+    var actor = DialogueManager.masterDatabase.GetActor(actorName);
+    if (actor != null)
+    {
+        foreach (var activeConversations in DialogueManager.instance.activeConversations)
+        {
+            activeConversations.conversationModel.OverrideCharacterInfo(actor.id, actorTransform);
+        }
+    }
+}
Unfortunately my game is organized so that player (with dialogue sys component) and level itself are two separate scene. And it is both possible. Start player scene and the in game use Load to load a scene. But it is also possible just to start level without player (nice option for dev) and then load dialogue system with player into it. (I am not a big fan of patching src of third party code, but in this case probably just to avoid 100+ error messages in console could be a good reason).

The problem I just do not have masterDatabase and all my NPCs have for some reason optional DialogueActor that calls RegisterActorTransform OnEnable().

I just added a null check there. My only question, it is some cache that will be updated. Is it safe or at least not very critical to ignore this on scene start for NPCs?

Re: First response deselected on dialogue start

Posted: Wed Dec 11, 2024 6:52 pm
by Tony Li
Hi,

Most Dialogue System functions assume a Dialogue Manager is present. But here's a patch that adds a DialogueManager.instance null check in this line:

Code: Select all

var actor = DialogueManager.masterDatabase.GetActor(actorName);
It should resolve the issue.

DS_CharacterInfoPatch_2024-12-11.unitypackage