Exemplo n.º 1
0
 protected override void OnStart()
 {
     base.OnStart();
     if (Value == -1)
     {
         Value = DefaultValue;
     }
     if (UpBtn != null)
     {
         UpBtn.AddClick(OnClickUpBtn);
         UpBtn.AddMouseDown(OnUpBtnDown);
         UpBtn.AddMouseUp(OnBtnMouseUp);
     }
     if (DownBtn != null)
     {
         DownBtn.AddClick(OnClickDownBtn);
         DownBtn.AddMouseDown(OnDownBtnDown);
         DownBtn.AddMouseUp(OnBtnMouseUp);
     }
     if (btnMax != null)
     {
         btnMax.AddClick(OnClickMaxBtn);
     }
     if (btnMin != null)
     {
         btnMin.AddClick(OnClickMinBtn);
     }
 }
Exemplo n.º 2
0
        protected override void OnStart()
        {
            base.OnStart();
            if (Btn != null)
            {
                Btn.AddClick(OnClickBtn);
                spNormal = Btn.normalSprite;
                spOver   = Btn.hoverSprite;
            }
            List.barInContent = true;
            UISprite btnSprite = Btn.GetComponent <UISprite>();

            if (isUpDirection)
            {
                List.transform.localPosition = new Vector3(List.transform.localPosition.x, List.ListHeight + 2, 0);
            }
            var objArrow = DisplayUtil.GetChildByName(Btn.transform, "spArrowDown");

            if (objArrow != null)
            {
                spArrow = objArrow.GetComponent <CButton>();
            }
            //else
            //{
            //    List.transform.localPosition = Btn.transform.localPosition + Vector3.down * btnSprite.height;
            //}
            //List.gameObject.SetActive(false);
            ActivieList(false);
        }
Exemplo n.º 3
0
 protected override void OnStart()
 {
     UIEventListener.Get(Track.gameObject).onPress  = OnPressTrack;
     UIEventListener.Get(Thumb.gameObject).onDrag   = OnDragThumb;
     UIEventListener.Get(Track.gameObject).onScroll = OnMouseScroll;
     UIEventListener.Get(Thumb.gameObject).onScroll = OnMouseScroll;
     if (hasStart == false)
     {
         if (UpBtn != null)
         {
             UpBtn.AddClick(OnClickUpBtn);
             UpBtn.AddMouseDown(OnUpBtnDown);
             UpBtn.AddMouseUp(OnBtnMouseUp);
         }
         if (DownBtn != null)
         {
             DownBtn.AddClick(OnClickDownBtn);
             DownBtn.AddMouseDown(OnDownBtnDown);
             DownBtn.AddMouseUp(OnBtnMouseUp);
         }
         hasStart = true;
     }
     //Thumb.transform.localPosition = Track.transform.localPosition + Vector3.right;
     if (value == 0)
     {
         Thumb.transform.localPosition = Track.transform.localPosition;//+ Vector3.right;
     }
 }
Exemplo n.º 4
0
 protected override void OnStart()
 {
     base.OnStart();
     if (Value == -1)
     {
         Value = DefaultValue;
     }
     if (UpBtn != null)
     {
         UpBtn.AddClick(OnClickUpBtn);
         UpBtn.AddMouseDown(OnUpBtnDown);
         UpBtn.AddMouseUp(OnBtnMouseUp);
     }
     if (DownBtn != null)
     {
         DownBtn.AddClick(OnClickDownBtn);
         DownBtn.AddMouseDown(OnDownBtnDown);
         DownBtn.AddMouseUp(OnBtnMouseUp);
     }
     if (btnMax != null)
     {
         btnMax.AddClick(OnClickMaxBtn);
     }
     if (btnMin != null)
     {
         btnMin.AddClick(OnClickMinBtn);
     }
     if (Input != null)
     {
         Input.onChange.Add(new EventDelegate(OnTextChange));
         Input.numOnly = true;
     }
     if (lblMax != null)
     {
         EventUtil.AddClick(lblMax.gameObject, OnLabelMax);
     }
     UIEventListener.Get(Input.gameObject).onSubmit = OnTextSubmit;
 }
Exemplo n.º 5
0
        public void SetDataProvider <T>(IEnumerable <T> value)
        {
            if (_itemRender == null)
            {
                Debug.LogError("set itemRender first!");
                return;
            }
            if (_itemPool == null)
            {
                _itemPool = new List <CItemRender>();
            }
            if (_allItem == null)
            {
                _allItem = new List <CItemRender>();
                btnLeft.AddClick(ScrollPre);
                btnRight.AddClick(ScrollNext);
            }
            SetData <T>(value);
            //_dataProvider = (value ?? new List<T>()) as List<object>;

            bool        isEnough = _allItem.Count >= _dataProvider.Count;
            int         n        = Mathf.Abs(_allItem.Count - _dataProvider.Count);
            CItemRender item;

            while (n > 0)
            {
                if (isEnough == true)
                {
                    item = _allItem[_allItem.Count - 1];
                    _itemPool.Add(item);
                    _allItem.RemoveAt(_allItem.Count - 1);
                    item.SetParent(recycle);
                    item.tran.localPosition = Vector3.zero;
                    item.SetActive(false);
                }
                else
                {
                    if (_itemPool.Count > 0)
                    {
                        item = _itemPool[0];
                        _itemPool.RemoveAt(0);
                        item.SetActive(true);
                    }
                    else
                    {
                        item = (CItemRender)Activator.CreateInstance(_itemRender);
                        EventUtil.AddHover(item, OnHover);
                        //item.width = itemWidth;
                    }
                    item.SetParent(_content.transform);
                    _allItem.Add(item);
                }
                n--;
            }
            ResetItems();
            lastDataProvider = value;
            lastMainItem     = _allItem[mainIndex];
            oriSizeX         = _allItem[mainIndex].width;
            oriSizeY         = _allItem[mainIndex].height;
            SetMainItemRender(lastMainItem, false);
        }