using UnityEngine;
using System.Collections; public class xt : MonoBehaviour
{ //红色血条
public Texture2D blood_red;
//黑色血条
public Texture2D blood_black;
//当前生命值
private int HP = ; void OnGUI()
{
if (GUILayout.RepeatButton("加血"))
{
//增加生命值
if (HP < )
{
HP++;
}
}
if (GUILayout.RepeatButton("减血"))
{
//减少生命值
if (HP > )
{
HP--;
}
}
//根据当前生命值计算红色血条显示的宽度
int blood_width = blood_red.width * HP / ;
//绘制黑色血条
GUI.DrawTexture(new Rect(, , blood_black.width, blood_black.height), blood_black);
//绘制红色血条
GUI.DrawTexture(new Rect(, , blood_width, blood_red.height), blood_red); }
}

资源下载

http://pan.baidu.com/s/1dDEjy9b

最新文章

  1. JavaScript——正则表达式
  2. linux复习
  3. http的响应对象
  4. View (二) 自定义属性
  5. PHP 设计模式 笔记与总结(2)开发 PSR-0 的基础框架
  6. ubuntu下安装mysql及外网访问设置
  7. mvc mvp mvvm区别
  8. php环境配置优化
  9. NodeJS+express+mogondb学习笔记01
  10. MSSQL查询数据分页
  11. poj 3696 The Luckiest Number
  12. Linux filesystem
  13. RoboMongo命令(版本:Robo 3T 1.1.1)
  14. jQuery: 选择器,筛选器
  15. Html的简单学习笔记
  16. SQL Server -&gt;&gt; DAC(Dedicated Administrator Connection)专用管理员连接
  17. InfluxDB中文文档
  18. PLSQL导出对象的表结构和表数据
  19. Eclipse导入包提示Setting build path has encountered a problem
  20. sql中exist()的用法

热门文章

  1. 一篇采访窥C#的未来
  2. Codeforces 670E - Correct Bracket Sequence Editor - [对顶栈]
  3. find实现特殊功能示例
  4. Python使用xml.dom解析xml
  5. OCR技术(光学字符识别)
  6. 最大似然估计(Maximum likelihood estimation)(通过例子理解)
  7. 转:Java中Scanner类和BufferReader类之间的区别
  8. 封装一个axios请求后台的通用方法
  9. python 去除微软的BOM
  10. 1-AO3402MOS管使用