Quantcast
Viewing all articles
Browse latest Browse all 56

Drawing a box with mouse dragged on screen

When a user clicks mouse0 I set a Vector2 orgBoxPos = Input.mousePosition; While he is holding down mouse0, I constantly update Vector2 endBoxPos = Input.mousePosition; I then try this to draw this box on the screen (ie: imagine an RTS style selection box): GUI.DrawTexture(new Rect(orgBoxPos.x, Screen.height - orgBoxPos.y, endBoxPos.x - orgBoxPos.x, Screen.height - endBoxPos.y - orgBoxPos.y), selectTexture); All of the Rect coords are correct except the last one (Remember unity GUI y coords are inverted, for some funky reason). For some reason I can't seem to figure out how to correctly calculate the end height of my rectangle. Any help would be greatly appreciated!

Viewing all articles
Browse latest Browse all 56

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>