- Home /
GUI error scripting help!
I've created this script to open a GUI Texfield. But there is an error in my script... error: "Assets/Scripts/TypeName.js(2,16): BCE0018: The name 'TextField' does not denote a valid type ('not found')"
Here is the script:
var stringToEdit : String = "Type in your NAME";
var TextArea : TextField;
function OnGUI () {
stringToEdit = TextArea.text;
}
I may be very wrong here, but have a review of the following question and answer and see if this assists:
http://answers.unity3d.com/questions/264120/how-do-i-keep-a-reference-to-editor-gui-objects.html
Answer by flamy · Jun 14, 2012 at 11:48 AM
hmmm TextField is not a class to so that you can declare a object for it, it is just a function in unity. you can call a function but not declare it as a type for a variable. From the method what i understand you are trying to do something like this...
var stringToEdit : String = "Hello World";
var viewportArea : Rect;
function OnGUI () {
// Make a text field that modifies stringToEdit.
stringToEdit = GUI.TextField (viewportArea, stringToEdit, 25);
}
is this what you want ???!!
Yes!! That was what I actually want! Thanks! :) edit: I tried the script but it keeps saying the same error.
Answer by Dissolver84 · Jun 16, 2012 at 02:41 AM
I still get the same problem, any help?
You are indeed using @flamy's script, and replaced all the code that was in your script? The error message really refers you to that script? Which line? (double-click the error in the Unity console).
Your answer
Follow this Question
Related Questions
"NullReferenceException" while trying to draw a texture (C#) 1 Answer
Why is the script rejecting me? 1 Answer
script connection 1 Answer
Is there an easy way to pop-up error messages 3 Answers
Helicopter script error 1 Answer