Quantcast
Channel: Latest Questions by Darthlemi
Viewing all articles
Browse latest Browse all 6

WorldToScreenPoint acting weird on Y.

$
0
0
I am drawing text boxes at the location of some game objects. When using WorldToScreenPoint the point that is being returned is fine on the X axis. However when the game object is at the bottom of the screen the text box float to the top of the screen. Here is the code void OnGUI() { Vector3 screenTransform = m_cCamera.WorldToScreenPoint(transform.position); Rect txtRect = new Rect(screenTransform.x , screenTransform.y ,80,40); // GUI.DrawTexture(txtRect,LargeTxtBubbleImg); if(new Rect(0,0,m_cCamera.camera.pixelWidth, m_cCamera.camera.pixelHeight).Contains(new Vector2(txtRect.x,txtRect.y))) { if(m_bTxtBubbleLarge == false) { if(GUI.Button(txtRect,screenTransform.y.ToString())) { m_bTxtBubbleLarge = true; } } else { txtRect.width *= 2; txtRect.height *= 2; if(GUI.Button(txtRect, "NEW STORY!")) { m_bTxtBubbleLarge = false; } } } }

Viewing all articles
Browse latest Browse all 6

Trending Articles



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