Esempio n. 1
0
    private void InitItem(ContentPos contentItem, UIItemBase preItem, Hashtable exhash, int idx)
    {
        preItem.gameObject.SetActive(true);
        //preItem.transform.localPosition = new Vector3(contentItem.Pos.x, contentItem.Pos.y, 0);
        //if (preItem._InitInfo != contentItem.Obj)
        {
            Hashtable hash;
            if (exhash == null)
            {
                hash = new Hashtable();
            }
            else
            {
                hash = new Hashtable(exhash);
            }

            hash.Add("InitObj", contentItem.Obj);
            hash.Add("InitIdx", idx);
            preItem.Show(hash);
            preItem._InitInfo = contentItem.Obj;

            preItem._ClickEvent      = _OnClickItem;
            preItem._PanelClickEvent = _OnClickPanel;
            contentItem.ShowItem     = preItem;
        }
    }
Esempio n. 2
0
    public void ShowContainerPos(UIItemBase selectPos, ShowContainerPosCallFunc callFunc = null)
    {
        if (selectPos == null)
        {
            return;
        }
        Hashtable hash = new Hashtable();

        if (callFunc != null)
        {
            hash.Add("callFunc", callFunc);
        }
        StartCoroutine(ShowSelectContainPos(selectPos, hash));
    }
Esempio n. 3
0
    public static IEnumerable <UIItemBase> WalkItems(this UIItemBase item)
    {
        if (item == null)
        {
            yield break;
        }
        yield return(item);

        foreach (var child in item.Items)
        {
            foreach (var subChild in child.WalkItems())
            {
                yield return(subChild);
            }
        }
    }
Esempio n. 4
0
    private IEnumerator ShowSelectContainPos(UIItemBase selectPos, Hashtable hash = null)
    {
        yield return(new WaitForFixedUpdate());

        if (_ScrollRect != null)
        {
            if (_ScrollTransform.rect.width < _ContainerObj.rect.width)
            {
                if (_ScrollRect.horizontal == true)
                {
                    float containerMaxX = _ContainerObj.sizeDelta.x;
                    float containPosX   = -selectPos.GetComponent <RectTransform>().anchoredPosition.x + _ScrollTransform.rect.width * 0.5f;
                    containPosX = Mathf.Clamp(containPosX, -(containerMaxX - _ScrollTransform.rect.width), 0);
                    _ContainerObj.anchoredPosition = new Vector2(containPosX, _ContainerObj.anchoredPosition.y);
                }
            }

            if (_ScrollTransform.rect.height < _ContainerObj.rect.height)
            {
                if (_ScrollRect.vertical == true)
                {
                    float containerMaxY = _ContainerObj.rect.height;
                    float containPosY   = -selectPos.GetComponent <RectTransform>().anchoredPosition.y - _ScrollTransform.rect.height * 0.5f;
                    containPosY = Mathf.Clamp(containPosY, 0, containerMaxY - _ScrollTransform.rect.height);
                    Debug.Log("containPosY:" + containPosY);
                    _ContainerObj.anchoredPosition = new Vector2(_ContainerObj.anchoredPosition.x, containPosY);
                }
            }
        }

        if (hash != null && hash.ContainsKey("callFunc"))
        {
            var callFunc = (ShowContainerPosCallFunc)hash["callFunc"];
            callFunc();
        }
    }
Esempio n. 5
0
        public static void Test(UIObject parent)
        {
            UIItemBase item = parent.AddChild <UIItemBase>(null, parent.graphicComponent.transform);

            item.InvokeAfterAllAssetsLoadDone(() => { item.Show("1", 2); });
        }
Esempio n. 6
0
    public void MenuClick(UIItemBase itemBase)
    {
        UISubMenuItem menuItem = itemBase as UISubMenuItem;

        if (menuItem == null)
        {
            return;
        }


        if (menuItem.SubLevel == 1)
        {
            if (menuItem != _SelectedSub1)
            {
                ClearSelect(1);
                ClearSelect(2);
                _SelectedSub1 = menuItem;
                _SelectedSub1.Selected();
                if (_SubBtns[_SelectedSub1].Count > 0)
                {
                    _SelectedSub1.OpenSubGO();
                    //foreach (var sub2 in _SubBtns[_SelectedSub1])
                    //{
                    //    sub2.ShowMenu();
                    //}
                    for (int i = 0; i < _SubBtns[_SelectedSub1].Count; ++i)
                    {
                        if (!_SubBtns[_SelectedSub1][i].ShowMenu())
                        {
                            continue;
                        }

                        //if(_SelectedSub2 == null)
                        _SelectedSub2 = _SubBtns[_SelectedSub1][i];
                    }

                    if (_SelectedSub2 != null)
                    {
                        MenuClick(_SelectedSub2);
                        _SelectedSub2.Selected();
                        _MenuClick.Invoke(_SelectedSub2.MenuObj);
                        return;
                    }
                }
            }
            else if (_SubBtns[_SelectedSub1].Count > 0)
            {
                ClearSelect(1);
            }
        }
        else
        {
            if (menuItem != _SelectedSub2)
            {
                ClearSelect(2);
                _SelectedSub2 = menuItem;
                _SelectedSub2.Selected();
            }
        }

        _MenuClick.Invoke(menuItem.MenuObj);
    }