Ejemplo n.º 1
0
        // Update is called once per frame
        void LateUpdate()
        {
            if (unit == null)
            {
                if (thisObj.activeInHierarchy)
                {
                    thisObj.SetActive(false);
                }
                return;
            }


            if (unit.IsDestroyed() || (unit.HP >= unit.GetFullHP() && unit.shield >= unit.GetFullShield()))
            {
                UIUnitOverlayManager.RemoveUnit(unit);
                unit = null;
                thisObj.SetActive(false);
                return;
            }


            if (!thisObj.activeInHierarchy)
            {
                return;
            }

            Vector3 screenPos = Camera.main.WorldToScreenPoint(unit.thisT.position + new Vector3(0, 1, 0));

            screenPos.z         = 0;
            rectT.localPosition = screenPos * UIMainControl.GetScaleFactor();

            sliderHP.value     = (unit.HP / unit.GetFullHP());
            sliderShield.value = (unit.shield / unit.GetFullShield());
        }
        void Awake()
        {
            instance = this;

            for (int i = 0; i < 20; i++)
            {
                if (i > 0)
                {
                    GameObject newObj = UI.Clone(unitOverlayList[0].gameObject);
                    unitOverlayList.Add(newObj.GetComponent <UIUnitOverlay>());
                }
                unitOverlayList[i].gameObject.SetActive(false);
            }
        }