- Home /
uGUI: ScreenPoint positioning of custom cursors
I'm just starting to experiment with the new uGUI, and I'm not sure how to get it to do what I have done in the past with OnGUI(). For example, in an 3D game I'm converting to 4.6b, I have a player object that is not always facing in the same direction as the main camera. For this reason, I replace the mouse cursor with a custom cursor to describe the camera's movement, and then I draw a crosshair texture with GUI.DrawTexture() to represent the facing of the player object.
The way I do this in 4.5 is to Screen.showCursor = false and draw a GUI.DrawTexture() at the Input.mousePosition.x and Screen.height - Input.mousePosition.y (both minus half the image size to center it). Can I do the same thing with the new uGUI in 4.6b (except put the pivots at the mousePosition maybe)? Will that work the same when placing an image on the canvas?
Secondly, I draw the crosshairs for the player object facing by finding the location 100 units in front of the player (transform.position + transform.forward * 100) and use WorldToScreenPoint to get the position for the GUI.DrawTexture(). Do I use the same process in order to place a GUI marker (which I want to remain the same size with respect to the screen... so I don't want to place it at a world coordinate... I think) in front of the player?
Thanks for your help!