嗯...这是我几个月之前写的,没想到又翻出来用上了
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Loading : MonoBehaviour
{
AsyncOperation async;//
public Slider slider;//进度条
public Text percent;//百分比的显示
public Text toolTip;//一些提示信息,装饰用的,可有可无吧
//public Sprite[] bg;//背景图片
//public Image loadingBG;
string[] tip;//提示的数组
public static string loadName;//要加载的场景的名字,用的时候先赋值给这个,然后再跳转到loading的这个场景
public const string loadThis = "Loading";//进度条君所在的场景
void Start()
{
//Debug.Log(bg.Length);
//int count = Random.Range(0, bg.Length);
//loadingBG.sprite = bg[count];//这里是做了一个进入场景随机播放一张图片的功能
tip = new string[26];//26个颜文字(づ ̄3 ̄)づ╭❤~
tip[0] = "(。・`ω´・)";
tip[1] = "w(゚Д゚)w";
tip[2] = "ヽ(✿゚▽゚)ノ";
tip[3] = "(づ ̄3 ̄)づ╭❤~";
tip[4] = "︿( ̄︶ ̄)︿";
tip[5] = "Hi~ o(* ̄▽ ̄*)ブ";
tip[6] = "~~( ﹁ ﹁ ) ~~~";
tip[7] = "(ˉ▽ ̄~) 切~~";
tip[8] = "✧(≖ ◡ ≖✿)";
tip[9] = "ヾ( ̄▽ ̄)Bye~Bye~";
tip[10] = "Ψ( ̄∀ ̄)Ψ";
tip[11] = "X﹏X";
tip[12] = "(๑¯◡¯๑)";
tip[13] = "ლ(╹◡╹ლ)";
tip[14] = "┻━┻ (ヽ(`Д ́)ノ( ┻━┻ ";
tip[15] = "(๑•̀ω•́ ๑) 酱酱酱";
tip[16] = "(σ゚∀゚)σ呦呦";
tip[17] = "(o・_・)ノ”(ノ_<。)别哭啦";
tip[18] = "=͟͟͞͞ =͟͟͞͞ ヘ( ´Д`)ノ 放我去死一死啊";
tip[19] = "(ノ°ο°)ノ";
tip[20] = "(▰╹◡╹▰)";
tip[21] = "✧( ु•⌄• )◞◟( •⌄• ू )✧";
tip[22] = "(っ´ω`)っ☂⊂(´ω`⊂ )";
tip[23] = "ԅ( ˘ω˘ ԅ)";
tip[24] = "( ·̀⊿·́)ง☎️110我要报警了!";
tip[25] = "༼⍤ ᷇Θ̵̵̵̤Θ᷆ ༽!! ༼: ᷇Θ̵̵̵̤Θ᷆:#༽ ☕ ͜ ༼ ᷇Θ̵̵̵̤Θ᷆ ⍤༽";
Invoke("ToolTip", Time.deltaTime);//这里本来是想着加载时间长的话可以隔一段时间换一个提示信息
StartCoroutine(StartLoading());//加载
}
IEnumerator StartLoading()
{
float i = 0;
float pro = 0;
async = EnterDoor.LoadSceneAsync(loadName);
async.allowSceneActivation = false;//控制加载场景是否激活
while (i < 100)
{
pro = async.progress;
if (i < async.progress * 100)
i++;
else if (async.progress >= 0.9f)
i++;
slider.value = i / 100;
percent.text = i.ToString() + "%";
yield return new WaitForEndOfFrame();
}
async.allowSceneActivation = true;
}
void ToolTip()
{
int i = Random.Range(0, tip.Length);
toolTip.text = tip[i];
}
}
最后附上我做好的二张图片