예제 #1
0
    private void CreateSlot()
    {
        if (_slotList.Count == 0 && _slotSample)
        {
            // 슬롯 크기
            Rect    realSlotSize = _slotSample.GetComponent <RectTransform>().rect;
            Vector2 rate         = BicycleUtil.GetRatioOfScreenResolution();

            // 비율 적용된 슬롯 사이즈
            _slotSize = new Vector2((realSlotSize.width + _spacing) * rate.x, realSlotSize.height * rate.y);

            // 화면에 보여질 슬롯 수
            var showCount = Convert.ToInt32(Math.Truncate(_scrollViewRect.rect.width / _slotSize.x));
            _showCount = showCount + 4;

            // 기본 슬롯 생성,배치
            for (int i = 0; i < _showCount; i++)
            {
                var slot    = Instantiate(_slotSample, _content.transform);
                var slotPos = slot.GetComponent <RectTransform>().anchoredPosition;
                slot.GetComponent <RectTransform>().anchoredPosition = new Vector2(_slotSize.x * i, 0);
                slot.AddComponent <UIScreenScaler>().InitScaler(UIScreenScaler.eUIType.Base);
                _slotList.Add(slot);
            }
        }
    }
예제 #2
0
 public void InitUIObject()
 {
     GameObject[] childs = BicycleUtil.GetChildsObject(gameObject);
     foreach (GameObject child in childs)
     {
         if (string.Equals(child.name, "Scroll View"))
         {
             _scrollView = child.GetComponent <ScrollRect>();
             _scrollView.onValueChanged.AddListener((_x) => { OnValueChangedScroll(); });
             _scrollViewRect = child.GetComponent <RectTransform>();
             _content        = BicycleUtil.GetChildObject(_scrollView.gameObject, "Content").GetComponent <RectTransform>();
         }
         else if (string.Equals(child.name, ""))
         {
         }
     }
 }