コード例 #1
0
ファイル: WindowBehavior.cs プロジェクト: aa3268/CandyStore
 public void createHealthBar()
 {
     if (worldCanvas == null) {
         worldCanvas = GameObject.Find ("HealthBarCanvas");
     }
     GameObject bar = (GameObject)Instantiate (Resources.Load ("prefabs/healthBar"));
     healthBar = bar.GetComponent<HealthBar> ();
     healthBar.setMaxHealth (maxHealth);
     healthBar.transform.SetParent (worldCanvas.transform, false);
     healthBar.setAttachedObjectPos (transform.position);
     LevelDirector.instance.addMaxHealth (maxHealth);
 }
コード例 #2
0
ファイル: EnemyScript.cs プロジェクト: aa3268/CandyStore
 public void createHealthBar()
 {
     if (worldCanvas == null)
     {
         worldCanvas = GameObject.Find ("HealthBarCanvas");
     }
     GameObject bar = (GameObject)Instantiate (Resources.Load ("prefabs/healthBar"));
     healthBar = bar.GetComponent<HealthBar> ();
     healthBar.setColor (Color.red);
     healthBar.transform.SetParent (worldCanvas.transform, false);
     healthBar.setAttachedObjectPos (transform.position);
     healthBar.gameObject.SetActive (false);
 }