In last week’s lecture I had some trouble with the script:
// GUI.js var label : String; var rect : Rect; function Update() { GUI.Label(rect, label); }
Unity was giving the error:
Assets/GUI.js(5,13): BCE0019: ‘Label’ is not a member of ‘GUI’.
I’ve finally worked out why. When you create this script it makes a new class called “GUI” which overrides the built-in GUI class. So when I try to call GUI.Label()
it looks for a Label
method on this script. There is none, so it causes an error.
The moral to the story is: Make sure your scripts don’t have the same names as builtin Unity classes. So don’t call your script GUI or Transform or GameObject.
No Comments so far ↓
There are no comments yet...Kick things off by filling out the form below.
You must log in to post a comment.