{"id":152,"date":"2010-09-28T20:55:01","date_gmt":"2010-09-29T03:55:01","guid":{"rendered":"http:\/\/blogs.unsw.edu.au\/comp1400\/?p=152"},"modified":"2010-09-28T20:55:01","modified_gmt":"2010-09-29T03:55:01","slug":"weird-bug","status":"publish","type":"post","link":"https:\/\/blogs.unsw.edu.au\/comp1400\/blog\/2010\/09\/weird-bug\/","title":{"rendered":"Weird Bug"},"content":{"rendered":"<p>In last week&#8217;s lecture I had some trouble with the script:<\/p>\n<pre>\r\n\/\/ GUI.js\r\nvar label : String;\r\nvar rect : Rect; \r\n\r\nfunction Update() {\r\n   GUI.Label(rect, label);\r\n}\r\n<\/pre>\n<p>Unity was giving the error:<\/p>\n<p><strong>Assets\/GUI.js(5,13): BCE0019: &#8216;Label&#8217; is not a member of &#8216;GUI&#8217;.<\/strong><\/p>\n<p>I&#8217;ve finally worked out why. When you create this script it makes a new class called &#8220;GUI&#8221; which <strong>overrides<\/strong> the built-in GUI class. So when I try to call <code>GUI.Label()<\/code> it looks for a <code>Label<\/code> method on <strong>this script<\/strong>. There is none, so it causes an error.<\/p>\n<p>The moral to the story is: <strong>Make sure your scripts don&#8217;t have the same names as builtin Unity classes<\/strong>. So don&#8217;t call your script GUI or Transform or GameObject.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In last week&#8217;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: &#8216;Label&#8217; is not a member of &#8216;GUI&#8217;. I&#8217;ve finally worked out why. When you create this script it makes a new [&hellip;]<\/p>\n","protected":false},"author":80,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[121],"tags":[],"class_list":["post-152","post","type-post","status-publish","format-standard","hentry","category-lectures"],"_links":{"self":[{"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/posts\/152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/users\/80"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/comments?post=152"}],"version-history":[{"count":8,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/posts\/152\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/posts\/152\/revisions\/160"}],"wp:attachment":[{"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/media?parent=152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/categories?post=152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/tags?post=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}