// Update is called once per frame void Update() { if (mTankShoot == null) { mTankShoot = target.GetComponent <tankShoot>(); } else { mAmmoAmount.text = "" + mTankShoot.mAmmoAmount[mAmmoIndex]; } }
// Use this for initialization void Start() { tankShoot shootStatus = mTarget.GetComponent<tankShoot>(); Vector3 pos = new Vector3(100, 60, 0); for (int i = 0; i < shootStatus.mShellObjects.Length; i++) { GameObject ui = (GameObject) Instantiate(mAmmoUI, pos, Quaternion.identity); SingleAmmoStatusUI uiScript = ui.GetComponent<SingleAmmoStatusUI>(); uiScript.mAmmoIndex = i; uiScript.target = mTarget; ui.transform.SetParent(transform); pos = pos + new Vector3(50, 0, 0); } }