UI布局如下
代码如下,血条的默认高度和宽度感觉没必要改变就没做相应的设置
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BossHpUI : MonoBehaviour
{
public float bossHp;
public float bossCurrentHp;
public int buckleBlood;
public Image currentHpUI;
public Image currentHpNode;
private float currentHPValue;
private RectTransform rect_currentHpUI;
private RectTransform rect_currentHpNode;
public GameObject DrawBloodUiEffect;
private void Start() {
InitBossHPUI(3000000);
currentHPValue = GetBossHPValue();
UpdateBossHp();
rect_currentHpUI = currentHpUI.GetComponent<RectTransform>();
rect_currentHpNode = currentHpNode.GetComponent<RectTransform>();
}
public void InitBo