I would like to ask how do I make some guiText to blink awhile and then disappear. It will reappear about like 5seconds later.
var txt00 : Transform[];
var txt0 : Transform[];
I would like to ask how do I make some guiText to blink awhile and then disappear. It will reappear about like 5seconds later.
var txt00 : Transform[];
var txt0 : Transform[];
Try using unity’s built in Animation tool to make the GUITEXT blink??
/* Flashing button example */
function OnGUI () {
if (Time.time % 5 < 1) {
if (GUI.Button (Rect (10,10,200,20), "Meet the flashing button")) {
print ("You clicked me!");
}
}
}
You can use the Coroutines and new Unity 4.6 GUI to achieve this very easily. Check this article here
If you just need the code, here you go
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class FlashingTextScript : MonoBehaviour {
Text flashingText;
void Start(){
//get the Text component
flashingText = GetComponent<Text>();
//Call coroutine BlinkText on Start
StartCoroutine(BlinkText());
}
//function to blink the text
public IEnumerator BlinkText(){
//blink it forever. You can set a terminating condition depending upon your requirement
while(true){
//set the Text's text to blank
flashingText.text= "";
//display blank text for 0.5 seconds
yield return new WaitForSeconds(.5f);
//display “I AM FLASHING TEXT” for the next 0.5 seconds
flashingText.text= "I AM FLASHING TEXT!";
yield return new WaitForSeconds(.5f);
}
}
}