用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血条 进度条 减血效果 这一章我们讲处理HUD的显示与隐藏,首先我们找到在第一章所提供的下载链接中找到Resources—》Content3中找到HUD.Unitypackage包,把它导入到我们的项目包中。这时我们会发现在Prefabs...
php进度条php进度条php进度条php进度条php进度条php进度条php进度条php进度条php进度条php进度条php进度条php进度条php进度条
渐变进度条 美化进度条 是进度条更美观 看起来更舒服
它不仅仅是一个Loading控件,同时还支持进度条 (ProgressBar)功能 。 它会在你需要的时候出现, 它支持 left,top,right,bottom 四个方向加载(变色),最重要的是,它可以是 文字,也可以是 图片,能够满足...
进度条0.bat进度条0.bat进度条0.bat进度条0.bat进度条0.bat进度条0.bat进度条0.bat进度条0.bat进度条0.bat进度条0.bat进度条0.bat进度条0.bat进度条0.bat
Java实现进度条 Java实现进度条 Java实现进度条 Java实现进度条 Java实现进度条
彩色进度条,图片进度条,渐变进度条,是进度条更美观
Android跑马进度条,普通进度条,自定义进度条
BS进度条BS进度条BS进度条BS进度条BS进度条BS进度条BS进度条BS进度条BS进度条BS进度条BS进度条
页面加载前弹出进度条,这里显示的进度条进度是不标准的,因为某些功能任务没有办法预估精准的处理进度,只是显示大概范围的进度条值。 b、精确数值进度条。点击button弹出进度条,点击button后会查询数据,通过...
DataGridView进度条 DataGridView进度条 DataGridView进度条 DataGridView进度条 DataGridView进度条
win8 小点进度条,自定义圆形进度条,wpf Progressbar进度条样式更改
圆形进度条 index.html圆形进度条 index.html圆形进度条 index.html圆形进度条 index.html圆形进度条 index.html圆形进度条 index.html圆形进度条 index.html圆形进度条 index.html圆形进度条 index.html
html版进度条进度条,用于上传文件进度读取
进度条进程显示 进度条进程显示 进度条进程显示.rar进度条进程显示.rar进度条进程显示.rar进度条进程显示.rar进度条进程显示.rar进度条进程显示.rar
UGUI实现的圆形进度条 可用于进度条显示 也可用于拖拽验证码的功能
javascript进度条实例 进度条加载实例
这个是进度条的使用方法,包括两种,一种是水平的进度条,另一种是默认的圆圈的进度条。
6种造型的进度条,AssetStore绝版付费下载,满足现有的进度条需求。
用两个方法实现进度条,切换,最小化恢复窗口,进度条正常,不假死!请用Microsoft Visual Studio 2008打开,或先执行EXE看看是否是自己需要的! 注: 下载资源时,看清楚此文档说明,我不是为了积分而放在这里,我...