Hi guys. I’m not sure if its possible to position a GUItext using screen size / coordinates. By that i mean using something like Screen.width / 2, Screen.height / 2 kinda thing like you can use for buttons etc. In the inspector i can see that the position is 0 -1 for it to be visible on the screen, anything over or under that is disappears entirely form view. As far as i know any GUI objects are placed using pixel or screen coordinates? The text im displaying changes depending on what time you finish the level, so sometimes its longer or shorter and i want the text to regardless of size always be in the middle of the screen. this is the code im working with.
var TimerAccess : GameObject ; // object script is attached to
var timeAccess : LevelTimer ; // script variable is attached too
var Score : GUIText;
var OneStar : GUITexture;
var TwoStars : GUITexture;
var ThreeStars : GUITexture ;
function Start (){
OneStar.enabled = false;
TwoStars.enabled = false;
ThreeStars.enabled = false;
Score.text = null;
timeAccess = TimerAccess.GetComponent(LevelTimer);
}
function OnControllerColliderHit (hit : ControllerColliderHit){
if (hit.collider.gameObject.name == "EndLevelTrigger")
{
Debug.Log("Hit trigger");
LevelTimer.LevelOneEnd = true ; // show buttons on other script.
// Temporarily disable controls
GetComponent(MouseLook).enabled = false;
GetComponent(CharacterController).enabled = false ;
GetComponent(FPSInputController).enabled = false ;
GetComponent(CharacterMotor).enabled = false ;
if (timeAccess.timecount < 60) // script you want to access (timeAccess) and variable (timecount) to want to compare.
{
Score.transform.position = Vector3 (Screen.width /2, Screen.height / 2, 0);
Score.text = "Excellent work" ;
ThreeStars.enabled = true;
Debug.Log("3 stars" );
}
when i use the score.transform .position and try to place it using screen coordinates it disappears from view. Let the help commence