private void HandlingHealthBarPosition() { Vector3 pointOnUI = Camera.main.WorldToScreenPoint(transform.position); if (SmallHealthBar) { Vector3 healthBarPosition = pointOnUI + Vector3.up * 20; SmallHealthBar.transform.position = healthBarPosition; SmallHealthBar.GetComponent <Image>().fillAmount = CurrentHealth / HealthMax; } if (SmallManaBar) { Vector3 manaBarPosition = pointOnUI + Vector3.up * 15; SmallManaBar.transform.position = manaBarPosition; SmallManaBar.GetComponent <Image>().fillAmount = CurrentMana / ManaMax; } }
protected override void Start() { base.Start(); Vector3 pointOnUI = Camera.main.WorldToScreenPoint(transform.position); if (SmallHealthBarPrefab) { Vector3 healthBarPosition = pointOnUI + Vector3.up * 20; SmallHealthBar = Instantiate(SmallHealthBarPrefab, healthBarPosition, Quaternion.identity, GameObject.Find("Canvas").transform); SmallHealthBar.SetActive(true); SmallHealthBar.GetComponent <Image>().fillAmount = CurrentHealth / HealthMax; } if (SmallManaBarPrefab) { Vector3 manaBarPosition = pointOnUI + Vector3.up * 15; SmallManaBar = Instantiate(SmallManaBarPrefab, manaBarPosition, Quaternion.identity, GameObject.Find("Canvas").transform); SmallManaBar.SetActive(true); SmallManaBar.GetComponent <Image>().fillAmount = CurrentMana / ManaMax; } }