how can I save text to input field with button?
Hello,
I would like to save text to input field by clicking a button. My aim is to make form which is easier to fill. There is a inputfield for gender. Now players have to fill it by writing. I would like it to work so that I have two buttons. Other button is man and other is women. So the player can just click a button instead of writing his or her´s gender. With the script below text appears to screen. How can I modify it so it saves the gender to inputfield? I would apprecieate any guidance. Cheers. I
using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class textBtn : MonoBehaviour {
 public Text mytext = null;
 public int counter = 0;
 public void changeText()
 {
     counter++;
     if (counter % 2 == 1)
     {
         mytext.text = "man";
     }
   
 }
}
Answer by dakshesh1010 · Oct 30, 2017 at 07:34 AM
You can use Drop Down Component instead. To create Drop down, right click on the canvas UI->Drowdown.
Follow this manual for dropdowns:
https://docs.unity3d.com/Manual/script-Dropdown.html
Use GetComponent().value to know which option is selected and use this value to identify what the user has used in the form.
[2]: https://docs.unity3d.com/Manual/script-Dropdown.html
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                