Change dialogue ui at runtime? Multiple dialogue UI prefab support?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
irongamer
Posts: 7
Joined: Tue Mar 01, 2022 11:42 pm

Change dialogue ui at runtime? Multiple dialogue UI prefab support?

Post by irongamer »

Spent some time searching the forum but failed to find an example, likely just missed it here or in the docs.

I'd basically like two UIs:
  • A dialogue UI (already setup and working)
  • A book/letter/note UI
Can the dialogue system controller change to different dialogue UIs at run time? I'm trying to keep most of the game text in the dialogue system database and would like to have book/note/letter content displayed with a different UI. I have one dialogue system controller and one dialogue UI prefab setup to handle actual dialogue.

Is there a best practice for launching different conversations in different dialogue UI prefabs? Should I be using two dialogue system controllers? I didn't see a way to choose a dialogue system controller or dialogue ui in the dialogue system trigger, so I'm not sure how to approach this idea.
Error412
Posts: 23
Joined: Sat Feb 05, 2022 4:52 am

Re: Change dialogue ui at runtime? Multiple dialogue UI prefab support?

Post by Error412 »

Hi, once Tony logs will surely give you a better answer than mine, but if you want to give it a try in the meantime this is what I did for a similar situation:
-Just one dialogue system controller
- Under the Dialogue Manager Canvas move the 2 dialogue UI prefabs you want to use. Assign the main one the Dialogue UI field of Dialogue System controller component.
- On the button that triggers your "book/note" dialogue add an Override Dialogue UI component http://www.pixelcrushers.com/dialogue_s ... e_u_i.html. Within it drag on the UI field your "book/note" UI object that you added to your Canvas.
User avatar
Tony Li
Posts: 21070
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change dialogue ui at runtime? Multiple dialogue UI prefab support?

Post by Tony Li »

Error412 is exactly right. Use an Override Dialogue UI component.

Interactable items such as books usually only exist in one scene. (To say it another way, they are not marked Don't Destroy On Load, so they don't persist across scene changes.) Since the book only exists in one scene, and since the Dialogue Manager persists across scene changes, assign a dialogue UI prefab asset or a scene-specific instance of your book dialogue UI to its Override Dialogue UI field. That way it won't lose its reference to the dialogue UI as you change through different scenes.
irongamer
Posts: 7
Joined: Tue Mar 01, 2022 11:42 pm

Re: Change dialogue ui at runtime? Multiple dialogue UI prefab support?

Post by irongamer »

Thank you so much for the replies! I had totally missed the "Override Dialogue UI component!" :mrgreen: :mrgreen: :mrgreen:
User avatar
Tony Li
Posts: 21070
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change dialogue ui at runtime? Multiple dialogue UI prefab support?

Post by Tony Li »

Glad to help!
timbecile
Posts: 110
Joined: Mon Mar 12, 2018 11:00 pm

Re: Change dialogue ui at runtime? Multiple dialogue UI prefab support?

Post by timbecile »

Hey Tony,

would this same setup work for cutscenes? Like one UI for regular dialog, and a different UI for a cutscene?
User avatar
Tony Li
Posts: 21070
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change dialogue ui at runtime? Multiple dialogue UI prefab support?

Post by Tony Li »

Absolutely! That's a common use for Override Dialogue UI.
Post Reply