Page 1 of 1
unity inputfield with Dialogue System Varibles
Posted: Fri Jan 10, 2020 5:51 am
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
Re: unity inputfield with Dialogue System Varibles
Posted: Fri Jan 10, 2020 9:13 am
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
Re: unity inputfield with Dialogue System Varibles
Posted: Fri Jan 10, 2020 2:35 pm
by Amine33
thank you Very Much .
Re: unity inputfield with Dialogue System Varibles
Posted: Fri Jan 10, 2020 3:00 pm
by Tony Li
Happy to help!