Answer the question
In order to leave comments, you need to log in
How to get text from InputField in new UI out of the box?
There is an InputField object named NameField. I'm trying to do this:
var NameField : GameObject; // в редакторе привязал к нему InputField
function Game_Start () {
var NameField_input =NameField.GetComponent("InputField");
var Name = NameField.text;
Debug.Log(Name);
}
Answer the question
In order to leave comments, you need to log in
I answer myself. Here is the code that worked:
var NameField : UnityEngine.UI.InputField; // в редакторе привязал к нему InputField
function Game_Start () {
var Name = NameField.text;
Debug.Log(Name);
}
You have a typo, you are not using the NameField_input that you got from the NameField. In general, it's better to start learning C #, it's not difficult.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question