- Home /
Inputfield text to String variable
Hello!
So what I'm trying to do is pretty much explained above, I just want to make a sting variable equal to the InputField's text. So this is my code:
function Name(n: UI.InputField){
name = n.text;
}
This function is called by the Inputfield with the EndEdit function.
And this is the error I get:
BCE0031: Language feature not implemented: Ambiguous(AirportController.name, UnityEngine.Object.name).
After some searching I understand that Im missing a "()" somewhere but I dont know where!
Any help please??? :)
Where do you declare the string name, i.e. var name: string;
?
I just say this:
var name: String;
With all the other variables. Before the Start function.
Answer by DPuzey · Jul 15, 2015 at 07:18 PM
You're not missing any brackets; it's that when you assign name = n.text
, the compiler can't work out what name
is.
You've declared your own var name
, but one also exists in the UnityEngine.Object
base class, and so it's impossible to know which one you mean in the current scope. Try renaming your name
to something else (say, AirportName
or _name
or similar).
Your answer
Follow this Question
Related Questions
Prevent focus from leaving inputfield 0 Answers
UI InputField text sometimes invisible? 1 Answer
Ui text to string ? 1 Answer