private void Start() { foreach (Unit u in UnitsManager.m_Instance.m_AllUnits) { GameObject healthbar = Instantiate(m_HealthbarTemplate, transform); healthbar.name = $"{u.name} Healthbar"; HealthbarContainer container = healthbar.GetComponent <HealthbarContainer>(); container.SetUnit(u); container.UnitSetHealthbar(); container.m_HealthChangeIndicator.GetComponent <HealthChangeIndicator>().Create(); } }
/// <summary> /// Set the healthbar of the unit. /// </summary> /// <param name="healthbar">The healthbar game object.</param> public void SetHealthbar(HealthbarContainer healthbar) { m_Healthbar = healthbar.GetComponent <HealthbarContainer>(); m_HealthChangeIndicatorScript = healthbar.m_HealthChangeIndicator.GetComponent <HealthChangeIndicator>(); }