Example #1
0
        IEnumerator _Building(UnitTower tower)
        {
            Slider    bar  = GetUnusedBuildingBar();
            Transform barT = bar.transform;

            while (tower != null && tower.IsInConstruction())
            {
                bar.value = tower.GetBuildProgress();

                if (mainCam == null)
                {
                    mainCam = Camera.main;
                    continue;
                }

                Vector3 screenPos = mainCam.WorldToScreenPoint(tower.thisT.position + new Vector3(0, 0, 0));
                barT.localPosition = (screenPos + new Vector3(0, -20, 0)) / UI.GetScaleFactor();
                bar.gameObject.SetActive(true);

                yield return(null);
            }
            bar.gameObject.SetActive(false);
        }