Not a member of 'int'?

Here’s one that puzzles me. From the Unity - GUI Basics page, I pasted in some code in my OnGUI function to see if it works. This is what is was:

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");

When I do this I get errors saying

However, if I create a fresh new script and put this in, it works fine! But I sorta need this within my player script. What am I doing wrong?

You probably have a variable called Screen. You can differentiate between them by using UnityEngine.Screen where you want the actual screen size, but it would be better not to use Screen yourself in the first place. This is an example of why it’s a good idea to follow the convention of lowercase names for variables, so you don’t collide with existing methods.

–Eric

8O

Holy crap you’re right!

hehe… that was dumb of me.
Thanks man!