创建一个UI文本

绑定如下脚本

指定这个文本

开始游戏后3秒自动消失

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MissionShow: MonoBehaviour
{
    public GameObject MissionBar;
    private float showTimer=3;
    // Start is called before the first frame update
    void Awake()
    {
        MissionBar.SetActive(true);
    }

    // Update is called once per frame
    void Update()
    {
        showTimer -= Time.deltaTime;
        if (showTimer < 0)
        {
            MissionBar.SetActive(false);
        }
    }
}

附完整教程:

Unity2d Rubys Adventure 课程设计报告

posted on 2020-06-11 00:59  海月CSDN  阅读(99)  评论(0编辑  收藏  举报