通过gui的GUI.DrawTexture方法来实现血条,如下图:
using UnityEngine;
using System.Collections;
/// <summary>
/// 血条
/// 小伍 QQ:16349023
/// </summary>
public class Wy2HealthBar : MonoBehaviour {
public Texture2D HealthBg;
public Texture2D Heathforce;
public Vector2 offset = new Vector2(13,15);
private Wy2AIHealth health;
void Setup()
{
health = GetComponent<Wy2AIHealth>();
}
void Reset()
{
Setup();
}
// Use this for initialization
void Start () {
Setup();
}
// Update is called once per frame
void Update () {
}
void OnGUI()
{
if (Event.current.type != E