RestoreOriginalUI() thows MissingReference Error

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

RestoreOriginalUI() thows MissingReference Error

Post by eeeli »

Hello,

I've identified a pretty edge case bug in my game that unfortunately breaks everything, and after a couple attempts I'm not exactly sure how to diagnose it. I apologize in advance that this is a long post, but I wanted to be able to provide as much specific information as I can to the situation, in case anything catches your eye as being the potential issue.

The bug is as follows:

A the end of certain conversations, when RestoreOriginalUI() is called in the DialogueSystemController, and line 1228 throws a MissingReferenceException error. Here's line 1228 of my version of the Dialogue UI.

Code: Select all

displaySettings.dialogueUI = (m_originalDialogueUI as MonoBehaviour).gameObject;
As far as I can tell the issue has to do with there not being a dialogueUI to reset to as the default one.

Here is some additional context, as I have narrowed down the instances where this happens.

In my game there are loops, and the same scene is reloaded to show a loop, naturally the Dialogue System is one of the few objects that is not destroyed. I have it set up to select a default Dialogue UI when the scene reloads each time.

The bug is only happening after the scene has reloaded once.

The bug is also only happening after initiating certain conversations in a particular order.

One type of conversation is a phone call - which has a specific Dialogue UI. Phone calls are started via script by calling DialogueManger.StartConversation(). I manually set the dialogue ui through script using DialogueManager.UseDialogueUI(). There is also a player Actor that has DialogueSettingsOverride that also points to the correct DialogueUI. Writing this out now that seems potentially redundant. If I initiate a phone call at the start of a loop everything is fine throughout the rest of the loop and the bug doesn't occur.

Another type of conversation is with in-world objects. These are started through triggering a DialogueSystemTrigger, and have a different DialogueUI than phone calls. There is an Actor used for these environmental dialogues that has a Dialgoue Setting Override attached to it, so that when the player initiates an in-world conversation it opens the right DialogueUI.

This is the specific condition that the bug occurs: After the first loop, so once the scene has reloaded once, if you initiate a conversation with an in-world object, when that conversation is done Unity throws the MissingReferenceException error. From then on out if you try to start any new conversations it will throw the same error and the conversation is never started.

However, if you happen to start a phone call conversation first, the error never occurs, and you can go on to have as many of either types of conversations as you like. In the next loop, the same holds true, as long as you start by having a phone conversation nothing bugs, and you're good for the rest of the loop, but if you start any loop other than the first one by having a conversation with an in-world object then the error is thrown.

I'm thinking it must be something about how I'm setting the DialogueUI of the main DialogueSystemController between loops, or perhaps the difference between setting the dialogue UI manually through script versus through an Override.

Again, I'm sorry that this is a long post. I really appreciate any insight you can shed on the situation. I'm also happy to provide any additional details you think might be relevant about my specific set up. Though I'm grateful I've dialed in on exactly when this is happening, none of my tweaks to my set up have resulted in any success.

Thanks in advance and no worries if nothing comes to mind, I understand this might be specific to my setup/not easily solved via a forum post.
User avatar
Tony Li
Posts: 22152
Joined: Thu Jul 18, 2013 1:27 pm

Re: RestoreOriginalUI() thows MissingReference Error

Post by Tony Li »

Hi,

Can you try backing up your project and updating to the latest version of the Dialogue System?

If so, then please let me know if the problem is still present after updating.
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: RestoreOriginalUI() thows MissingReference Error

Post by eeeli »

Hello, I'm more than happy to try that.

I made a backup and upgraded to the latest version. I went from 2.2.22 to 2.2.25.1. Everything else is stable as far as I can tell, but unfortunately the bug is still persistent and behaving in the exact same way.
User avatar
Tony Li
Posts: 22152
Joined: Thu Jul 18, 2013 1:27 pm

Re: RestoreOriginalUI() thows MissingReference Error

Post by Tony Li »

Hi,

Would it be possible for you to send a reproduction project to tony (at) pixelcrushers.com? If you prefer, you can send exact reproduction steps assuming a new, empty project containing only the Dialogue System.
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: RestoreOriginalUI() thows MissingReference Error

Post by eeeli »

Hi!

I don't want to jinx it, but I think I fixed. Before setting up the reproduction project I took a careful look at what I was doing differently calling the two different kinds of conversations. The reason the Phone Call version was working was because I was calling a DialogueManager.UseDIalogueUI() from the script that starts the calls.

After reloading the scene the Dialogue Manager loses it's default DialogueUI. I thought I had previously fixed this by having a little script that reset the default DialogueUI of the Dialogue Manager between loads. However, it turns out I wasn't setting the dialogue ui correctly.

Originally I had the following code called on scene loads:

Code: Select all

DialogueManager.displaySettings.dialogueUI = PhoneInputManager.current.phoneDialogueUI;
I think this was the incorrect way to access/set those display settings. Because once I changed it to this everything is now running smoothly as I reset the scene.

Code: Select all

DialogueManager.UseDialogueUI(PhoneInputManager.current.phoneDialogueUI);
Thanks for the offer to go over a reproduction! Also, probably good that I went about updating the Dialogue System as part of bug-fixing, seems good to be on the most recent version :)
User avatar
Tony Li
Posts: 22152
Joined: Thu Jul 18, 2013 1:27 pm

Re: RestoreOriginalUI() thows MissingReference Error

Post by Tony Li »

Great! If the issue pops up again, just drop a note here and we can look into it further.
Post Reply