// Update is called once per frame void LateUpdate() { if (unit == null) { if (thisObj.activeInHierarchy) { thisObj.SetActive(false); } return; } if (unit.IsDestroyed() || (unit.HP >= unit.GetFullHP() && unit.shield >= unit.GetFullShield())) { UIUnitOverlayManager.RemoveUnit(unit); unit = null; thisObj.SetActive(false); return; } if (!thisObj.activeInHierarchy) { return; } Vector3 screenPos = Camera.main.WorldToScreenPoint(unit.thisT.position + new Vector3(0, 1, 0)); screenPos.z = 0; rectT.localPosition = screenPos * UIMainControl.GetScaleFactor(); sliderHP.value = (unit.HP / unit.GetFullHP()); sliderShield.value = (unit.shield / unit.GetFullShield()); }
public void SetUnit(Unit tgtUnit) { unit = tgtUnit; sliderShield.gameObject.SetActive(unit.GetFullShield() <= 0 ? false : true); }