コード例 #1
0
 private void Start()
 {
     if (player == null)
     {
         player = GameObject.FindObjectOfType <PlayerHealthSystemTest>();
     }
     SceneManager.sceneUnloaded += DereferencePlayerHealth;
     healthText = GetComponentInChildren <TextMeshProUGUI>();
     UpdateHealthText(player.GetCurrentHP());
     player.OnPlayerHealthUpdate += UpdateHealthText;
 }
コード例 #2
0
 private void MakeThisObjectSingleton()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }