Set Up Dialogue System for Mobile

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
bhavinsavajiyani
Posts: 42
Joined: Sun Jul 26, 2020 3:51 pm

Set Up Dialogue System for Mobile

Post by bhavinsavajiyani »

Hello,
First of all, Dialogue System is an amazing asset and reduces burden of the developer to create a proper dialogue system! I am using this system for a mobile game that I'm developing!


I'm relatively new & have some initial roadblocks:

1) I followed the quick start guide and created a sample scene of my own, with 2 characters (Player & NPC) having a conversation! I've used the Basic Standard Dialogue UI.
I just wanted to experiment what would happen, if I used the default Settings of Dialogue System and develop an Android Build. It was impressive to see, that buttons did work, when touched, and almost all the behaviour was adapted automatically to work for platform.
But, one issue I came across was, that I ended up having very small fonts & regular panel sizes, with difficult to use option buttons! I had not made any changes to the Dialogue System's UI & built the sample scene. Is there any way by which I could change the font sizes, and allow the canvas to scale as per screen sizes, leaving the panels & Entire UI intact?
Snapshot of Sample Scene on Android.jpg
Snapshot of Sample Scene on Android.jpg (369.08 KiB) Viewed 895 times

2) I have a situation where my NPC would be asking some questions to Player & I would require player input at certain instances during the flow of conversation. I might require Text Fields, drop downs, date selection, etc. at certain instances! What should I do, in order to trigger a Text Field or other relevant UI components, after completion of a certain dialogue of NPC?

For instance my NPC would ask player to provide First name. After the question has been asked by NPC, "What is your first name?", I should get a text field after completion of dialogue! And my target platform is mobile here, so when Text Field is instantiated, some custom placeholder text needs to be displayed, and the placeholder needs to be different for different textfields which would further be initiated in flow of conversation, & onscreen keyboard should open up when text field is touched, and should close, if tapped anywhere outside the area of keyboard. Also, the text field should be visible when player is typing, and might be pushed a bit upwards automatically, when onscreen keyboard pops up & pushed back down to it's normal position when keyboard closes.
Once player has typed & presses "OK" or "Done" or "Tick mark button, on android keyboard which is next to space bar", the conversation needs to progress to next line. Meanwhile, when onscreen keyboard is open & back button of Android OS is pressed, the keyboard should close, but the conversation should remain intact.
Also, I need to put up a condition, where in if player inputs nothing in the textfield or does not input anything when UI components are provided for input and presses "OK" or "Done", an alert or popup comes & the conversation should not proceed ahead, unless player provides required input.

Apart from that, I need to utilise the value of player's input in the further use of dialogues!
For instance, when user enters the relevant details in textfield, First Name here as per above mentioned scenario, I need to save that value. Then when player chooses some date, I need to save that as well.
Also, I need a way, to store that value to my custom database, so I can perform CRUD operations with it later on, at other instances, for future use!


3) Is there any easier/direct way, to synchronise camera cutscenes and audio & text of dialogues, to work in proper sequence, based upon dynamic lengths of text dialogues?


Hoping for a fruitful response!
Any help would be appreciated!
Also, a huge thanks in advance, for any sort of help.

Kind Regards,
Bhavin.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Set Up Dialogue System for Mobile

Post by Tony Li »

Hi,
Thanks for using the Dialogue System!
bhavinsavajiyani wrote: Mon Jul 27, 2020 6:42 am 1) ...one issue I came across was, that I ended up having very small fonts & regular panel sizes, with difficult to use option buttons! I had not made any changes to the Dialogue System's UI & built the sample scene. Is there any way by which I could change the font sizes, and allow the canvas to scale as per screen sizes, leaving the panels & Entire UI intact?
Add a Canvas Scaler to the Dialogue Manager's Canvas. Set it to Scale With Screen Size. Then set a reference resolution, such as 800x600 or 1920x1080. Adjust the UI elements (panel sizes, font sizes) to look the way you want. Let's say you use a reference resolution of 960x540. Then, if you build to a device that uses 1920x1080, the Canvas Scaler will double the size of everything.
bhavinsavajiyani wrote: Mon Jul 27, 2020 6:42 am2) I have a situation where my NPC would be asking some questions to Player & I would require player input at certain instances during the flow of conversation. I might require Text Fields, drop downs, date selection, etc. at certain instances! What should I do, in order to trigger a Text Field or other relevant UI components, after completion of a certain dialogue of NPC?
For text input, use the TextInput() sequencer command. See DemoScene1's conversation with the computer terminal for an example. The TextInput() sequencer command shows a text input field and stores the player's input in a Dialogue System variable.
bhavinsavajiyani wrote: Mon Jul 27, 2020 6:42 amApart from that, I need to utilise the value of player's input in the further use of dialogues!
You can reference that Dialogue System variable in dialogue entry nodes' Conditions and Script fields. You can also show it in Dialogue Text by using the [var=variable] markup tag.

There is no built-in provision for dropdowns, but you can write a similar sequencer command. Look at SequencerCommandTextInput.cs for an example.
bhavinsavajiyani wrote: Mon Jul 27, 2020 6:42 am3) Is there any easier/direct way, to synchronise camera cutscenes and audio & text of dialogues, to work in proper sequence, based upon dynamic lengths of text dialogues?
I recommend watching the Cutscene Sequences tutorials.

More info:
bhavinsavajiyani
Posts: 42
Joined: Sun Jul 26, 2020 3:51 pm

Re: Set Up Dialogue System for Mobile

Post by bhavinsavajiyani »

Thank You Tony for sharing your knowledge!
Much appreciated! :D

I would also like to know the specifics, for execution of such a scenario, as mentioned
bhavinsavajiyani wrote: Mon Jul 27, 2020 6:42 am For instance my NPC would ask player to provide First name. After the question has been asked by NPC, "What is your first name?", I should get a text field after completion of dialogue! And my target platform is mobile here, so when Text Field is instantiated, some custom placeholder text needs to be displayed, and the placeholder needs to be different for different textfields which would further be initiated in flow of conversation, & onscreen keyboard should open up when text field is touched, and should close, if tapped anywhere outside the area of keyboard. Also, the text field should be visible when player is typing, and might be pushed a bit upwards automatically, when onscreen keyboard pops up & pushed back down to it's normal position when keyboard closes.
Once player has typed & presses "OK" or "Done" or "Tick mark button, on android keyboard which is next to space bar", the conversation needs to progress to next line. Meanwhile, when onscreen keyboard is open & back button of Android OS is pressed, the keyboard should close, but the conversation should remain intact.
Also, I need to put up a condition, where in if player inputs nothing in the textfield or does not input anything when UI components are provided for input and presses "OK" or "Done", an alert or popup comes & the conversation should not proceed ahead, unless player provides required input.
I have tried using TextInput() sequencer command. But,
1) I am not able to find a way of setting placeholder text, for different text fields.

2) The onscreen keyboard opens up automatically, when text field is instantiated. And when the onscreen keyboard opens up, the text field gets covered up by the keyboard.
Keyboard.jpg
Keyboard.jpg (310.18 KiB) Viewed 883 times
3) I am also not able to proceed to next line of conversation, when I press "Ok" or "Done" from the onscreen keyboard.

4) How can I set a condition, to NOT allow player to proceed ahead, without providing required input, when text field is instantiated? Also, how can we trigger an alert-box/pop-up, when the player tries to proceed without providing any input?


And I had created a text variable for storing first name. I was able to use it in dialogues, which I suppose surely works in sync with the database created using the Dialogue System itself.
But what if I have to save that particular value, provided by player at the time of input, to my custom database?
Is there any way by which we could do it?
Or is there any way by which we could pass the value stored in "variable" which is created using database of Dialogue System, to my custom, hosted database?

Hoping for a fruitful response!

Kind Regards,
Bhavin.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Set Up Dialogue System for Mobile

Post by Tony Li »

Hi,
bhavinsavajiyani wrote: Mon Jul 27, 2020 3:21 pmI have tried using TextInput() sequencer command. But,
1) I am not able to find a way of setting placeholder text, for different text fields.
Before calling TextInput(), set the variable that TextInput() will use. Take the demo's Terminal conversation, for example. If I wanted the placeholder text to be "*****", I'd set the dialogue entry node's values to:
  • Dialogue Text: "Enter password:"
  • Script: Variable["password"] = "*****";
  • Sequence: TextInput(Text Field UI,Password,password)
bhavinsavajiyani wrote: Mon Jul 27, 2020 3:21 pm2) The onscreen keyboard opens up automatically, when text field is instantiated. And when the onscreen keyboard opens up, the text field gets covered up by the keyboard.
Reposition the text field UI element so it's above the onscreen keyboard.
bhavinsavajiyani wrote: Mon Jul 27, 2020 3:21 pm3) I am also not able to proceed to next line of conversation, when I press "Ok" or "Done" from the onscreen keyboard.
Configure the keyboard to call the text field UI's StandardUIInputField.AcceptTextInput() method. Or, if the player dismisses the keyboard, call CancelTextInput().
bhavinsavajiyani wrote: Mon Jul 27, 2020 3:21 pm4) How can I set a condition, to NOT allow player to proceed ahead, without providing required input, when text field is instantiated? Also, how can we trigger an alert-box/pop-up, when the player tries to proceed without providing any input?
Please see the Terminal conversation. If you don't enter the correct password, it doesn't allow you to proceed. You can do something similar. If the player doesn't enter the correct information, use ShowAlert("message") in the Script field, and loop back to the node before the TextInput() sequencer command.
bhavinsavajiyani wrote: Mon Jul 27, 2020 3:21 pmAnd I had created a text variable for storing first name. I was able to use it in dialogues, which I suppose surely works in sync with the database created using the Dialogue System itself.
But what if I have to save that particular value, provided by player at the time of input, to my custom database?
To get the value, use DialogueLua.GetVariable:

Code: Select all

using PixelCrushers.DialogueSystem;
...
string password = DialogueLua.GetVariable("password");
Alternatively, keep in mind that the Dialogue System has a save system. You can get all of the Dialogue System's data using PersistentDataManager.GetSaveData() and restore it using PersistentDataManager.ApplySaveData(). If you use the full save system (which can save GameObject positions, active/enabled states, animator states, etc.), you'll use SaveSystem.SaveToSlot and LoadFromSlot instead.
bhavinsavajiyani
Posts: 42
Joined: Sun Jul 26, 2020 3:51 pm

Re: Set Up Dialogue System for Mobile

Post by bhavinsavajiyani »

I would surely take into consideration, the solutions you provided & work accordingly.
Thank you very much Tony!
Your help is much appreciated. :D
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Set Up Dialogue System for Mobile

Post by Tony Li »

Happy to help! :-)
Post Reply