- Home /
guiText/GameObject position
I try to set up a guiText above a gameobject and I realize that the position of one is linked to the position of the other:
oLoader.guiText.transform.position = new Vector2(0.2f, 0.2f);
This code places the guiText correctly but also acts on the gameobject and replace with the same coordinates
oLoader.transform.position = new Vector3(55f, 70f, -85f);
This code places the gameobject correctly in 3D space but guiText've been in and out of the screen
Have an idea? :)
Sorry for my english, GoogleTrad is a good english Friend.
Answer by aldonaletto · Jul 25, 2011 at 03:13 AM
You can use a script from @Eric5h5 called ObjectLabel - click here to access it. It associates a GUIText to some object, and works even if the object moves.
Answer by YikYikHeiHei · Jul 12, 2011 at 11:24 AM
guiText position X range is 0-1 and position Y range 0-1 too.
function Start ()
{
this.transform.position = new Vector3(0.3f,0.7f,1.0f);
}
This code places in the guiText gameobject.
var oLoader : GameObject; // place your guiText
function Start ()
{
oLoader.transform.position = new Vector3(0.5f,0.7f,1.0f);
}
Or you can places this code in a gameObject.
I think it can help you.
Two functions start? Currently I use a gameobject which I attach a GUIText. So for now I get the GUIText attach and I try to move it, but it also moves gameobject ..
How to divide your two functions start?
sorry this is my first week of Unity:)
It is two script, and the first script is attach your GUIText. and the last script is attach a gameObject.