【Unity】用NGUI实现血条和伤害显示
2015-01-26 19:28
302 查看
using UnityEngine;
using System.Collections;
public class create_HP : MonoBehaviour {
public GameObject HP_prefab; //预设的血条
public Transform create; //生成的地点
public GameObject hudtext; //头顶伤害显示预设
//Use this for initialization
void Start()
{
GameObject go= GameObject.Instantiate(HP_prefab, HP_prefab.transform.position, Quaternion.identity) as GameObject;
go.transform.parent = create;
go.transform.localPosition = Vector3.zero;
}
//Update is called one per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
GameObject hud = GameObject.Instantiate(hudtext, hudtext.transform.position, Quaternion.identity) as GameObject;
hud.transform.parent = create;
hud.transform.localPosition = Vector3.zero;
}
}
}
using UnityEngine;
using System.Collections;
public class DESTORY : MonoBehaviour {
//本脚本用来销毁预设的伤害显示
//Use this for initialization
void Start()
{
Destroy(this.gameObject, 2.1f);
}
//Update is called one per frame
void Update()
{
}
}
using System.Collections;
public class create_HP : MonoBehaviour {
public GameObject HP_prefab; //预设的血条
public Transform create; //生成的地点
public GameObject hudtext; //头顶伤害显示预设
//Use this for initialization
void Start()
{
GameObject go= GameObject.Instantiate(HP_prefab, HP_prefab.transform.position, Quaternion.identity) as GameObject;
go.transform.parent = create;
go.transform.localPosition = Vector3.zero;
}
//Update is called one per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
GameObject hud = GameObject.Instantiate(hudtext, hudtext.transform.position, Quaternion.identity) as GameObject;
hud.transform.parent = create;
hud.transform.localPosition = Vector3.zero;
}
}
}
using UnityEngine;
using System.Collections;
public class DESTORY : MonoBehaviour {
//本脚本用来销毁预设的伤害显示
//Use this for initialization
void Start()
{
Destroy(this.gameObject, 2.1f);
}
//Update is called one per frame
void Update()
{
}
}
相关文章推荐
- unity 使用NGUI 显示角色血条和名字
- 【Unity&NGUI】圆环血条制作&以及多层圆环血条的实现
- Unity的NGUI插件的HUD Text插件血条数值的显示
- unity_NGUI_实现点击鼠标左键切换给定图集中的图片显示
- 关于Unity中NGUI的3D角色血条的实现
- NGUI名字跟随、伤害显示、血条和miss效果的制作
- 【Unity】NGUI实现技能冷却脚本
- 最新 unity 血条的另类制作-伤害减血加血自动回血
- Unity手游开发--NGUI实现冷却技能(CD)功能
- ngui 实现聊天系统中玩家输入表情与文字结合显示
- Unity在NGUI中默认动态字体Arial字体显示不完整解决方案
- 【Unity】用NGUI实现摇杆功能
- Unity 3d之NGUI【特效制作 1】 制作血条,能量条
- Unity拖拽NGUI中的Texture效果实现
- NGUI实现血条
- unity实现血条随人物的移动
- Unity技术详解之血条的实现
- Unity利用NGUI实现自定义鼠标
- unity+ngui 输入框显示系统中文字体的方法
- Unity-基于NGUI下的序列帧动画代码实现