Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

GUIText viewporttoworldpoint makes text disappear.

$
0
0
Hi All. I've created a GUIText, whoch defaults to the center of my screen. I know I can move it around using the Pixel Offset, but I want it to be consistant regardless of the aspect ratio, so I added the following script to another gameObject, referencing the GUI: var clipDisplay : GUIText; var clipDisplayX = 0.5; var clipDisplayY = 0.5; var thisCam : Camera; function Update() { clipDisplay.guiText.transform.position = thisCam.ViewportToWorldPoint(Vector3(clipDisplayX, clipDisplayY, 0)); } The clipDisplayX and Y are set to 0.5, the idea being I can adjust them in the Inspector window to find the position I need. But when I add the ViewportToWorldPoint line, the GUIText disappears from the game. I know it'll be just somewhere out of sight, but I can't find it. I've adjusted the X and Y values, and added the thisCam variable to ensure it's using the right camera. I've even tried changing the font and material out of desperation, but no avail. I'm sure it's something simple I'm missing... If I comment out that one line, the GUI comes back to the center. Strange. I'm out of ideas, can anybody help please? Cheers Ian

Viewing all articles
Browse latest Browse all 171066

Trending Articles



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