AR校园解谜——技术文档

发布时间 2023-04-23 14:53:43作者: 不用去猜mk

①start界面加载进度条实现:

 首先在层级栏新建一个Image,在image下新建一个Text文本。

image作为进度条的样式,text为进度条上显示的文本。

 在camera组件下绑定脚本Load Scene,脚本选择的对象是之前新建的Image和Text,如下图

 脚本代码:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using TMPro;

public class LoadScene : MonoBehaviour
{
    public TextMeshProUGUI loadingText;
    public Image progressBar;
    private int curProgressValue = 0;

    void FixedUpdate()
    {
        int progressValue = 100;

        if (curProgressValue < progressValue)
        {
            curProgressValue++;
        }

        loadingText.text = $"游戏加载中...{curProgressValue}%";//实时更新进度百分比的文本显示  

        progressBar.fillAmount = curProgressValue / 100f;//实时更新滑动进度图片的fillAmount值  

        if (curProgressValue == 100)
        {
            loadingText.text = "OK";//文本显示完成OK
            SceneManager.LoadScene("Menu");
        }
    }
}

②UI的优化

 考虑到unity自带UI过于简陋,所以选择更换UI的贴图,操作如下

首先选中需要更换贴图的button

 接下来点击Image的源图像,在你的资源中选择你需要更换的贴图,完成你的UI优化。

 ③剧情介绍界面的打字机效果实现