血条的制作有很多的方法,在此介绍使用GUI制作血条的方法,希望对大家有所帮助:
using UnityEngine;
using System.Collections;
public class PlayerHealth : MonoBehaviour {
//玩家最大血量
public int maxHealth =100;
//玩家当前血量
public int curHealth = 100;
//血条的长度
public float healthBarLength;
void Start () {
//设置血条的长度等于屏幕宽度的一半
healthBarLength = Screen.width /