- Home /
Question by
jkm8 · Aug 08, 2015 at 12:27 PM ·
scripting problem
Appear a text at start in the center of the screen
So i've made a script, Apperently, it doesnt work.
function OnStart() { lay = app.CreateLayout( "linear", "VCenter,FillXY" );
txt = app.CreateText( "Hello" );
txt.SetTextSize( 32 );
lay.AddChild( txt );
app.AddLayout( lay);
}
Comment
Oh and also, i want it to dissapear for after like, 3 or 4 seconds.
If this is supposed to be invoked automatically, change OnStart() to Start() and see what that does.
Best Answer
Answer by NotEnoughLemons3D · Aug 09, 2015 at 10:17 PM
If you wish to use GUI
var showText = true;
var showTime : int = 4;
function Start (){
Invoke("Stop",showTime);
}
function OnGUI (){
if(showText == true){
GUI.Label(Rect((Screen.width/2)-50,Screen.height/2,100,50),"Hello World");
}
}
function Stop (){
showText = false;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220611234919im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
In game menu 1 Answer
Application.isPlaying returning true when I exit play mode 0 Answers
2D water script, player in water physics 1 Answer
Line render from an object to a click 0 Answers