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 to
BCE0019: '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.
I name the script name Screen.js but I wonder how it work to execute code so it will find the script name?
– lypanAll 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 instead of the Screen class that comes with Unity.
– Bunny83