- Home /
'width' and 'height' are not members of 'Screen'?
I follow the tutorial to execute
function OnGUI () {
GUI.Box (Rect (0,0,100,50), "Top-left");
GUI.Box (Rect (Screen.width - 100,0,100,50), "Top-right");
GUI.Box (Rect (0,Screen.height - 50,100,50), "Bottom-left");
GUI.Box (Rect (Screen.width - 100,Screen.height - 50,100,50), "Bottom-right");
}
but it comes toBCE0019: 'width' is not a member of 'Screen'.
BCE0019: 'height' is not a member of 'Screen'.
and due to the script reference, I think that they are members of screen.
How should I fix it? Thx in advance.
Answer by Bunny83 · Apr 24, 2013 at 09:09 AM
You named one of your own classes / scripts "Screen". rename it! Never use built-in classnames for your own stuff.
I name the script name Screen.js but I wonder how it work to execute code so it will find the script name?
All your scripts are actually classes. The file name is the class name. So when you write Screen.width somewhere else it will try to find the width variable on your class ins$$anonymous$$d of the Screen class that comes with Unity.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Setting Scroll View Width GUILayout 1 Answer
Mouse ignore object 2 Answers
Two Unity GUI questions 2 Answers