unity3d中怎么制作关卡载入进度条
展开全部
下面的代码是我在网上找到的,自己还没看过,希望对你有帮助。不过自带的GUI里面有很多比较好的东西,你只需要组合调用就可以产生很多你想要的效果,当然有时候你不想要的效果也有可能出现,呵呵
/*
用Unity做血条或进度条真的很方便,GUI里scrollbar就可以轻松实现,再加上lerp一个血条或进度条就完成了。
*/
using UnityEngine;
using System.Collections;
public class BloodBarTest : MonoBehaviour {
public GUISkin theSkin;
public float bloodValue = 0.0f;
private float tmpValue;
private Rect rctBloodBar;
private Rect rctUpButton;
private Rect rctDownButton;
private bool onoff;
// Use this for initialization
void Start () {
rctBloodBar = new Rect (20,20,20,200);
rctUpButton = new Rect (50,20,40,20);
rctDownButton = new Rect (50,50,40,20);
tmpValue = bloodValue;
}
void OnGUI (){
GUI.skin = theSkin;
if (GUI.Button (rctUpButton,"加血")){
tmpValue = -1.0f;
}
if (GUI.Button (rctDownButton,"减血")){
tmpValue += 0.1f;
}
if (bloodValue > 0.0f) tmpValue = 0.0f;
if (bloodValue < -1.0f) tmpValue = -1.0f;
bloodValue = Mathf.Lerp(bloodValue,tmpValue,0.05f);
//~ Debug.Log (bloodValue + " " + tmpValue);
GUI.VerticalScrollbar(rctBloodBar, 1.0f, bloodValue,0.0f, 1.0f,GUI.skin.GetStyle("verticalScrollbar"));
}
// Update is called once per frame
void Update () {
}
}
/*
用Unity做血条或进度条真的很方便,GUI里scrollbar就可以轻松实现,再加上lerp一个血条或进度条就完成了。
*/
using UnityEngine;
using System.Collections;
public class BloodBarTest : MonoBehaviour {
public GUISkin theSkin;
public float bloodValue = 0.0f;
private float tmpValue;
private Rect rctBloodBar;
private Rect rctUpButton;
private Rect rctDownButton;
private bool onoff;
// Use this for initialization
void Start () {
rctBloodBar = new Rect (20,20,20,200);
rctUpButton = new Rect (50,20,40,20);
rctDownButton = new Rect (50,50,40,20);
tmpValue = bloodValue;
}
void OnGUI (){
GUI.skin = theSkin;
if (GUI.Button (rctUpButton,"加血")){
tmpValue = -1.0f;
}
if (GUI.Button (rctDownButton,"减血")){
tmpValue += 0.1f;
}
if (bloodValue > 0.0f) tmpValue = 0.0f;
if (bloodValue < -1.0f) tmpValue = -1.0f;
bloodValue = Mathf.Lerp(bloodValue,tmpValue,0.05f);
//~ Debug.Log (bloodValue + " " + tmpValue);
GUI.VerticalScrollbar(rctBloodBar, 1.0f, bloodValue,0.0f, 1.0f,GUI.skin.GetStyle("verticalScrollbar"));
}
// Update is called once per frame
void Update () {
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不知道有没有插件显示的,研究中...现在3.0了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |