Changing Dialogue UI on runtime

Announcements, support questions, and discussion for the Dialogue System.
GreenishFlow
Posts: 5
Joined: Thu Mar 31, 2016 12:17 pm

Re: Changing Dialogue UI on runtime

Post by GreenishFlow »

Tony Li wrote:Since the Dialogue System is modular, your UI options are really wide open. You're not confined to the way that the UnityUIDialogueUI class does it. You could write your own UI script that implements the IDialogueUI interface. It's only a handful of methods like ShowSubtitle and ShowResponses.

If you want to use the Unity UI scripts that come with the Dialogue System, here are a few ideas:

- In OnLinkedConversationStart, record the current conversation (DialogueManager.CurrentConversationState) and then stop it (DialogueManager.StopConversation). Then call UseDialogueUI to change the dialogue UI. Finally, call the version of DialogueManager.StartConversation that lets you start a conversation at a specific dialogue entry ID.

- Or, use a single UnityUIDialogueUI script. When you want to switch UIs, just swap out all the UI element assignments (e.g., NPC Subtitle Panel, NPC Subtitle Line, etc.). If you're using the Conversation Log Dialogue UI from the Extras page, this idea may require a little adjustment.
Thanks for advice. But DialogueManager.CurrentConversationState is null for liked conversation.
May be you can tell me how to get a title of the current linked conversation? thanks
addym55
Posts: 7
Joined: Tue Mar 29, 2016 6:33 am

Re: Changing Dialogue UI on runtime

Post by addym55 »

Hi,

What you said were exactly the ideas in my mind, but I wasn't able to execute them.

1.
How will you distinguish between multiple choice questions and regular dialogues?
- I added 4 responses and linked them to a parent response. Correct response links to a NPC dialogue, while the rest 3 to the other NPC Dialogue.
I start the timer after clicking the parent response.
Please check the image. Image
If this is not the correct way of making MCQs please suggest the best method.

2.
If a response is a multiple choice question, add it to the fixed Buttons list. Otherwise add it using the Button Template.
- Is it possible to do this in same conversation? Can I add the response to a fixed button or template on runtime?


3.
Change the timer to show an animated sprite instead of controlling a slider.
- To do this, should I make changes in UnityUIResponseMenuControls script (i.e. change the timer type and all the functions related to it) or is there a direct and easy way to do this ?

I hope my questions are clear. I have recently started to work on Dialogue System and I'm still exploring it.

Thanks for your time.

Cheers
addym55
Posts: 7
Joined: Tue Mar 29, 2016 6:33 am

Re: Changing Dialogue UI on runtime

Post by addym55 »

BTW, I tried what you advised to @GreenishFlow. StopConversation() and StartConversation() did work and I was able to replace the UI on runtime.

I am posting the function I used for replacing UI on runtime. Hope this will be helpful to @GreenishFlow (if you still need this).

Code: Select all

public void ReplaceUI(string i)
	{
		int id = int.Parse(i);
		string title = DialogueManager.LastConversationStarted;
		DialogueManager.StopConversation();
		DialogueManager.UseDialogueUI(UI2);
		DialogueManager.StartConversation(title,DialogueManager.CurrentActor,DialogueManager.CurrentConversant,id);

		Debug.Log("UI Replaced");
	}
In the Conversation Graph, I used sequence when I wanted to replace UI.

Code: Select all

SendMessage(ReplaceUI,3,); 

This works like a charm, made my day :)

Cheers
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing Dialogue UI on runtime

Post by Tony Li »

Hi,
addym55 wrote:1.
How will you distinguish between multiple choice questions and regular dialogues?
- I added 4 responses and linked them to a parent response. Correct response links to a NPC dialogue, while the rest 3 to the other NPC Dialogue.
I start the timer after clicking the parent response.
Please check the image. Image
If this is not the correct way of making MCQs please suggest the best method.
Can you clarify what you mean by "dialogue line?" If I understand you correctly, I think you just want to show some dialogue entry nodes as "spoken" text (called a subtitle in the Dialogue System) and others as a menu of buttons that the player can choose from (called a response menu in the Dialogue System). For example, in this image:
Image
these nodes would be shown in the NPC Subtitle or PC Subtitle text elements:
  • PC: "Hi, are you looking for so..."
  • NPC: "Yes! Actually, I have lost..."
  • NPC: "Can you please guide me to..."
  • PC: "Sure"
  • NPC: "Thanks a lot!"
  • NPC: "I'm not sure if you are right..."
  • NPC: "Thanks anyway!"
And these nodes would all be in a single response menu:
  • (Button) "Go to the Second Floor..."
  • (Button) "Go to the Hospital..."
  • (Button) "It's on College First Floor..."
  • (Button) "I don't know"
If you want it to work that way, use these steps:
  1. Inspect the Dialogue Manager. Tick Subtitle Settings > Show PC Subtitles During Line.
  2. UNtick Input Settings > Always Force Response Menu. When this is unticked, the conversation will only show a response menu if the PC has more than one option. If there's only one option, it will automatically play it as a subtitle.
addym55 wrote:2.
If a response is a multiple choice question, add it to the fixed Buttons list. Otherwise add it using the Button Template.
- Is it possible to do this in same conversation? Can I add the response to a fixed button or template on runtime?
Yes, but if I my understand above is correct, then you shouldn't need to do this. If my understanding it incorrect, let me know and I'll put together an example scene.
addym55 wrote:3.
Change the timer to show an animated sprite instead of controlling a slider.
- To do this, should I make changes in UnityUIResponseMenuControls script (i.e. change the timer type and all the functions related to it) or is there a direct and easy way to do this ?
The example will include the updated Unity UI support scripts that will be in the next 1.6.0.2 release. They're just minor updates, but they include things like the ability to overwrite the way timers work.

Thanks for posting the ReplaceUI code. I think it'll be helpful to other people!
addym55
Posts: 7
Joined: Tue Mar 29, 2016 6:33 am

Re: Changing Dialogue UI on runtime

Post by addym55 »

Hi,
If you want it to work that way, use these steps:

Inspect the Dialogue Manager. Tick Subtitle Settings > Show PC Subtitles During Line.
UNtick Input Settings > Always Force Response Menu. When this is unticked, the conversation will only show a response menu if the PC has more than one option. If there's only one option, it will automatically play it as a subtitle.
This works great for me. Thanks a lot! :)

You mentioned 1.6.0.2 update.. How soon should I expect it?? I'll probably leave the default timer until new update.
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing Dialogue UI on runtime

Post by Tony Li »

I expect to release 1.6.0.2 by this upcoming Friday, if not sooner, on the Pixel Crushers website. The Unity Asset Store folks usually take a few more business days to make it available on the Asset Store.
addym55
Posts: 7
Joined: Tue Mar 29, 2016 6:33 am

Re: Changing Dialogue UI on runtime

Post by addym55 »

That's great!!

Keep up the good work. Kudos!!

Cheers
addym55
Posts: 7
Joined: Tue Mar 29, 2016 6:33 am

Re: Changing Dialogue UI on runtime

Post by addym55 »

Hi

While I was implementing default Timer for MCQs, I found that once the time is over, the flow goes to the 1st option and it is not bypassing the options as I expected it to do. This was working fine when I was using Force Response Menu, but now it is not. Could you please tell what can be the reason?

Thanks for your time.

Cheers
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing Dialogue UI on runtime

Post by Tony Li »

Hi,
addym55 wrote:While I was implementing default Timer for MCQs, I found that once the time is over, the flow goes to the 1st option and it is not bypassing the options as I expected it to do. This was working fine when I was using Force Response Menu, but now it is not. Could you please tell what can be the reason?
That's by design. You can configure the Dialogue System to do one of three things on timeout:

1. End the conversation. (Set via Dialogue Manager > Input Settings.)

2. Or, simulate a click of the first response in the menu. (Set via Dialogue Manager > Input Settings.)

3. Or, simulate a click of the currently-selected response in the menu. (Set in Unity UI Dialogue UI > Response Menu > Select Current On Timeout checkbox.)

On timeout, the Dialogue System also sends an "OnConversationTimeout" script message to the Dialogue Manager. You can add a script to the Dialogue Manager that has an OnConversationTimeout() method that does something other than one of those three things above.
Post Reply