Advertisemen
This video will show you how to make auto typing letter by letter in unity 3d in a really simple way.
Codes used in above video. This modified code block is for Unity 5x so if you are using Unity 4x, please uncomment one saying for Unity 4x and comment out one saying for Unity 5x.
using UnityEngine;
using System.Collections;
public class AutoTyping : MonoBehaviour {
string myString = "This is a auto typing text...";
// Use this for initialization
void Start () {
StartCoroutine("AutoType");
}
// Update is called once per frame
IEnumerator AutoType () {
foreach(char letter in myString.ToCharArray()){
GetComponent<GUIText>().text += letter; //for unity 5x
// guiText.text += letter; // for unity 4x
yield return new WaitForSeconds(0.3f);
}
}
}
using System.Collections;
public class AutoTyping : MonoBehaviour {
string myString = "This is a auto typing text...";
// Use this for initialization
void Start () {
StartCoroutine("AutoType");
}
// Update is called once per frame
IEnumerator AutoType () {
foreach(char letter in myString.ToCharArray()){
GetComponent<GUIText>().text += letter; //for unity 5x
// guiText.text += letter; // for unity 4x
yield return new WaitForSeconds(0.3f);
}
}
}
If this video is helpful, please like, comment, share and subscribe.
Thank you
Advertisemen
Tidak ada komentar:
Posting Komentar