public void InitializeUI() { player.OnEnable(); try { _healthbarSettings.healthbarTransform = healthbar.GetComponentsInChildren <Transform>()[2]; player.DamageTaken += OnTakeDamage; } catch (UnassignedReferenceException) { Debug.LogError("The healthbar and related objects were not assigned in the UI canvas! Disabling updates!"); } try { _ammoSettings.text = ammo.GetComponent <TMP_Text>(); PWC.OnEnable(); _ammoSettings.wep = PWC.GetEquippedWeapon(); _ammoSettings.uIndic = uiReloadIndicator; _ammoSettings.uFill = uiReloadIndicatorMask.transform; _ammoSettings.uFillFull = uiReloadIndicatorMask.transform.localScale.x; EquippedWeapon.WeaponAmmoChanged += OnWeaponUpdate; EquippedWeapon.WeaponSwapped += OnWeaponSwap; PWC.ReloadUpdate += OnReloadUpdate; } catch (UnassignedReferenceException) { Debug.LogError("The ammo counter and related objects were not assigned in the UI canvas! Disabling updates!"); } if (score != null) { _scoreSettings.text = score.GetComponent <TMP_Text>(); } else { Debug.LogError("The score was not assigned in the UI canvas! Disabling Updates!"); } if (deathMessage != null) { player.Died += OnDeath; } else { Debug.LogError("The death message was not assigned in the UI canvas! Disabling updates!"); } DungeonGameManager.ScoreChanged += OnScoreChanged; UpdateAmmo(); UpdateHealthbar(); UpdateScore(); fadeOut.gameObject.SetActive(true); }