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); }
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); }