- Home /
GUI Cross Hair Positioning
OK this is driving me nuts!! I tried followint this tutorial but every time my cross hair for my gun keeps showing up in the upper left hand corner of the screen, what am I missing??
var crosshairTexture : Texture2D; var position : Rect; function Start() { position = Rect( ( Screen.width - crosshairTexture.width ) / 2, ( Screen.height - crosshairTexture.height ) / 2, crosshairTexture.width, crosshairTexture.height ); } function OnGUI() { GUI.DrawTexture( position, crosshairTexture ); }
Answer by Jason B · Feb 04, 2011 at 12:58 AM
Run an actual build of your game instead of playing it in the editor.
I've found that one bug is that while playing in the editor, your GUIs show up further up and to the left than they actually are. It is extremely irritating, but I don't know of a fix for this behavior. Perhaps changing the aspect ratio in the editor viewport to 4:3. Not sure.
Thanks, I;ll have to try thay because when I have my window split at 2 by 3 and play in the editor it does show up center, so maybe that's it.
Thought I would quickly chime in with my results on your tip, thank you very kindly for that. I ran a build and it worked fine, plus I changed my window view to 2 by 3 and in the editor player it showed up fine, only if you play it full screen in the editor it shows up in the top left corner of the screen, now only if the tutorial, as awesome as it was had mentioned that, that would happen it would have saved me hours of frustration lol
Hopefully this will help out anyone else's confusion on that issue who is new to Unity ;)
Thanks again for the quick reply to I really apreciate that :)
I got the problem too ... I'm try to change position while playing . but when i play it a gain , it back to same position , DA$$anonymous$$N :(
Your answer
![](https://koobas.hobune.stream/wayback/20220613102729im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Using Percentage to Move Object 1 Answer
Dealing with multiple crosshairs 0 Answers
Simple GUI In game 1 Answer
Make a GUI.Box with an outline AND a transparent center? 1 Answer