unity inputfield with Dialogue System Varibles

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Amine33
Posts: 22
Joined: Mon May 21, 2018 4:48 pm

unity inputfield with Dialogue System Varibles

Post by Amine33 »

for example ...
The player wants to sell a weapon
NPC Will ask him ..how much do want ....
Then the player writes the price in inputfield
If the price that the player wrote, for example, is greater than 50
Npc will refuse
If the price is less than 50 ...Npc Will accpet
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: unity inputfield with Dialogue System Varibles

Post by Tony Li »

Hi,

You can use the TextInput() sequencer command to show an input field. Most of the prefab dialogue UIs include an input field named "Text Field UI". It accepts any kind of text. You can either change its Unity UI InputField component to only accept numbers, or make a new one that only accepts numbers. Let's say you copy Text Field UI to a new one named "Number Field UI". Then use this Sequence:
  • Dialogue Text: "How much do you want?"
  • Sequence: TextInput(Number Field UI, Amount, price)
In "TextInput(Number Field UI, Amount, price)", the "Number Field UI" specifies the name of the input field to use. "Amount" is the label to show. "price" is the variable to store the input (e.g., Variable["price"]).

Link an empty node after this. The empty node is required to make the conversation delay one node before checking the value. This is because conversations have to check one node ahead to support certain continue button modes.

The link two nodes from the empty node. Node 1:
  • Dialogue Text: "Okay, I accept."
  • Conditions: tonumber(Variable["price"]) <= 50
Node 2:
  • Dialogue Text: "I refuse. That's too expensive."
  • Conditions: tonumber(Variable["price"]) > 50
Amine33
Posts: 22
Joined: Mon May 21, 2018 4:48 pm

Re: unity inputfield with Dialogue System Varibles

Post by Amine33 »

thank you Very Much .
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: unity inputfield with Dialogue System Varibles

Post by Tony Li »

Happy to help!
Post Reply