歡迎來到unity學習、unity培訓、unity企業培訓教育專區,這裏有很多U3D資源、U3D培訓視頻、U3D教程、U3D常見問題、U3D項目源碼,我們致力於打造業內unity3d培訓、學習第一品牌。
1.首先創建一個GUIText對象。
2.在Project面板中新建一個C#腳本命名爲FadingMessage,雙擊該腳本進行編輯,添加如下代碼。
using UnityEngine;
using System.Collections;
public class FadingMessage : MonoBehaviour
{
float DURATION = 2.5f;
// Update is called once per frame
void Update()
{
if (Time.time > DURATION)
{
Destroy(gameObject);
}
//guiText.text = Time.time.ToString();
Color newColor = guiText.material.color;
float proportion = (Time.time / DURATION);
newColor.a = Mathf.Lerp(1, 0, proportion);
guiText.material.color = newColor;
}
更多精彩請點擊 http://www.gopedu.com/