How to use existing dialogue UI, and not create new instance?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
darkmalice
Posts: 4
Joined: Fri Jul 01, 2022 10:24 am

How to use existing dialogue UI, and not create new instance?

Post by darkmalice »

Hi, nooby question.
I'm using the SMS Dialogue UI, which I have in the scene under an existing hierarchy here under the contentDialogue panel.
Capture11.JPG
Capture11.JPG (32.32 KiB) Viewed 263 times
However, at runtime the DialogueManager will always instantiate it's own SMS Dialogue UI from the prefab, and referencing the Cellphone canvas will just cause it to instantiate it there.
So, how would one go about forcing DialogueManager to not instantiate, and instead use the existing scene object?
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to use existing dialogue UI, and not create new instance?

Post by Tony Li »

Hi,

Assign your existing scene instance of the SMS Dialogue UI to the Dialogue Manager's Dialogue UI field.

However, if your game changes scenes, your Cellphone GameObject must survive scene changes, since the Dialogue Manager survives scene changes. Otherwise the Dialogue UI field will end up pointing to nothing after a scene change. For an explanation with screenshots, see this article. It explains it in the context of a Player GameObject instead of a Cellphone GameObject, but it's the same idea.

If your Cellphone doesn't survive scene changes, you can use an Override Dialogue UI component on one of the participants (and assign your SMS Dialogue UI scene instance), or assign the dialogue UI at runtime in a script, such as:

Code: Select all

void Start()
{
    DialogueManager.UseDialogueUI(your_SMSDialogueUI_Scene_Instance);
}
darkmalice
Posts: 4
Joined: Fri Jul 01, 2022 10:24 am

Re: How to use existing dialogue UI, and not create new instance?

Post by darkmalice »

Thanks for the reply.
I've actually already tried assigning the SMS Dialogue UI to the Dialogue Manager's Dialogue UI field, to no avail.
cap1.JPG
cap1.JPG (36.18 KiB) Viewed 258 times
It seems determined to create it's own object.

And thank you for the advice on changing scenes, I'm sure that will be useful going forward.
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to use existing dialogue UI, and not create new instance?

Post by Tony Li »

Hi,

Please double-check that the SMS Dialogue UI that's inside Cellphone ... ContentDialogue is assigned to the Dialogue Manager's Dialogue UI field.

Here's a test scene that's set up that way:

DS_UseSceneDialogueUITest_2022-07-01.unitypackage
darkmalice
Posts: 4
Joined: Fri Jul 01, 2022 10:24 am

Re: How to use existing dialogue UI, and not create new instance?

Post by darkmalice »

Yeah it's the right one.
It appears to be because ContentDialogue is inactive, and even though I'm setting it active before triggering DS Use(), the DS is too quick and goes ahead to make it's own instance. If I leave the ContentDialogue active it will indeed use the assigned object.

Thanks for your help Toni, I'm sure I can fudge it now.
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to use existing dialogue UI, and not create new instance?

Post by Tony Li »

Glad to help! You can leave ContentDialogue and SMS Dialogue UI active, and deactivate Alert Panel and Dialogue Panel. The SMS Dialogue UI will automatically activate Alert Panel and Dialogue Panel as needed.
Post Reply