Bubble UI Subtitle Panel Not Working With “On Enable”

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
WeakInteractive
Posts: 15
Joined: Fri Nov 20, 2020 4:21 pm

Bubble UI Subtitle Panel Not Working With “On Enable”

Post by WeakInteractive »

Hello,

I'm experiencing an issue where the "Bubble Template Standard UI Subtitle Panel" doesn't appear when it's supposed to, and is instead replaced by the regular dialogue UI. I've been losing my mind over this issue for a while now, and I've finally made some progress on figuring out the cause.

After spending over an hour completely unable to figure out why it wasn't working in my own project, I downloaded the "BubbleSubtitleExample_2018-08-22" files from your website. Sure enough, it was working fine in that project. After messing around for a while, I realized that if I started the example conversation from an empty object using a "Dialogue System Trigger" component with "On Enable," I could reproduce the issue.

I've tested this a lot, and I can consistently reproduce the issue, but I can't figure out the exact cause. In the example scene, changing the "Dialogue System Trigger" component on the NPC to "On Enable" still works, but removing the component and re-adding it completely breaks everything for some reason.

Here is a short video repro of the issue:

The video begins with the example scene completely untouched. I only show one way of reproducing the issue here, but after testing, it's not just the "Dialogue System Trigger" component that breaks things; starting conversations through C# in the OnEnable() method also causes the bubble UI to not appear.

Unity 2020.3.29f1
Dialogue System for Unity 2.2.25.1

Any help with this would be greatly appreciated. I really like starting conversations using OnEnable(), so it's a really big issue for me to not be able to do that.

Thank you for your time, and I look forward to hearing from you.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Bubble UI Subtitle Panel Not Working With “On Enable”

Post by Tony Li »

Hi,

That's related to Character GameObject Assignments.

In that video, the NPC GameObject has a Dialogue Actor component. This Dialogue Actor component tells the actor to use a custom subtitle panel (the bubble panel).

The easiest way to handle it in your scene is to assign the GameObject with the Dialogue Actor component to the Dialogue System Trigger's Conversation Conversant field. This way the conversation will use this GameObject for the conversation. It will find the Dialogue Actor on the GameObject, and so it will know to use the bubble panel.
WeakInteractive
Posts: 15
Joined: Fri Nov 20, 2020 4:21 pm

Re: Bubble UI Subtitle Panel Not Working With “On Enable”

Post by WeakInteractive »

Thank you for the reply.

Unfortunately, I'm still extremely confused. I apologize if I'm missing something obvious.

I tried adding the NPC/Player to the "Conversation Actor" and "Conversation Conversant" fields, but it still doesn't work for me. Video demonstration:


I also don't understand why simply removing the "Dialogue System Trigger" component from the NPC object, and then adding it back with identical settings causes the UI to vanish. Video demonstration:
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Bubble UI Subtitle Panel Not Working With “On Enable”

Post by Tony Li »

Try assigning the NPC GameObject to the Dialogue System Trigger's Conversation Conversant.

The difference between OnEnable and OnStart may be in when the Dialogue Actor component's OnEnable() runs versus when the Dialogue System Trigger's OnEnable() runs. By assigning the NPC GameObject to Conversant Conversant, you're not dependent on the timing of the two OnEnable() methods.
WeakInteractive
Posts: 15
Joined: Fri Nov 20, 2020 4:21 pm

Re: Bubble UI Subtitle Panel Not Working With “On Enable”

Post by WeakInteractive »

Does it work when you do this? Could it be my version of Unity or something?

I'm setting the NPC to be the Conversation Conversant exactly as you say, but "On Enable" still doesn't work.

Here is another example:


All I'm doing is removing the component that's already there, adding a new one, assigning the NPC, conversation, and setting it to "On Enable," and it just doesn't work for some reason. The original component worked fine, but the new one I add doesn't and I don't understand why.

Am I missing a setting? The only changes made to the example scene are the ones I make in the video.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Bubble UI Subtitle Panel Not Working With “On Enable”

Post by Tony Li »

Hi,

It's probably still a timing issue between various scripts' OnEnable() methods. To confirm this, disable the Dialogue System Trigger component before playing the scene. After entering play mode, enable the Dialogue System Trigger component. I'm guessing this will work correctly. If so, it's most likely a timing issue between the Dialogue Manager GameObject's OnEnable() methods and the Dialogue System Trigger's OnEnable(). For solutions, you could set the Dialogue System Trigger to OnStart or disable the Dialogue System Trigger component and use a Timed Event component to enable it after 1 frame.

Side note: In your latest video, I saw that you assigned NPC to the Conversation Conversant, so it should always use the bubble panel instead of the default subtitle panel. If you see it use the default panel even though NPC is assigned to Conversation Conversant, let me know. That shouldn't happen, though.
WeakInteractive
Posts: 15
Joined: Fri Nov 20, 2020 4:21 pm

Re: Bubble UI Subtitle Panel Not Working With “On Enable”

Post by WeakInteractive »

Yes, that does indeed seem to be the problem, delaying the OnEnable() method by 1 frame solves the issue.

That was really throwing me for a loop, and I'm still not entirely sure why certain things are behaving the way they are, like removing and re-adding the "Dialogue System Trigger" causing different behavior.

I've got the solution now though, so thanks a lot for the help!
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Bubble UI Subtitle Panel Not Working With “On Enable”

Post by Tony Li »

Oh, sorry, I forgot to answer that part. Unity doesn't guarantee the order in which OnEnable() methods run*, so removing and re-adding the component may have changed the order in which its OnEnable() was called.

* Technically you can use Edit > Project Settings > Script Execution Order to specify which scripts run before or after others, but Dialogue System Trigger doesn't do this. If you wanted to do so in your own project, you could try adding Dialogue System Trigger to the Script Execution Order list and setting its execution value to something higher than 0.
WeakInteractive
Posts: 15
Joined: Fri Nov 20, 2020 4:21 pm

Re: Bubble UI Subtitle Panel Not Working With “On Enable”

Post by WeakInteractive »

I thought that may have been the case (and most likely is the case), but unfortunately changing the script execution order didn't change anything for me; not sure why, but as long as I have a consistent workaround, I'm happy.

Thanks again!
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Bubble UI Subtitle Panel Not Working With “On Enable”

Post by Tony Li »

Glad to help!
Post Reply