Hello guys,
I got a little problem. I would like to add a text into a box, that I can change dynamically with C#.
It kinda looks like that:
The GUITEXT elements and my “box” are children of the camera I’m using.
I got a funktion that shows me the textbox. It works perfektly one time…
If I try to use this function a second time the text is somewhere in the world where it isn’t supposed to be. Or at least where I don’t want it to be.
What am I doing wrong? Here is an example of code I am using:
Vector3 screenPos = Camera.main.WorldToScreenPointMyTextBox.transform.position);
float x2 = screenPos.x / Screen.width;
float y2 = screenPos.y / Screen.height;
MyText.transform.position = new Vector3(x2+0.02f,y2+0.13f,0.98f);
I guess I mess up the coordinates somehow, but where?
Why does it work the first time but won’t work right the second time?
Is it because the objects are children of the main camera?
Thanks for any help!