示例#1
0
        private IEnumerator HideSubMenu(UIButton button)
        {
            if (button == null)
            {
                yield break;
            }
            button.GetComponent <UIButton>().normalSprite = SpriteUnToogle;
            button.GetComponent <UIButton>().hoverSprite  = SpriteUnToogle;
            UIRankButton rankButton = button.GetComponent <UIRankButton>();

            if (rankButton != null)
            {
                rankButton.DisActive();
            }

            if (!mRankTypeToSubMenu.ContainsKey(button.name))
            {
                yield break;
            }

            List <string> items = mRankTypeToSubMenu [button.name];

            foreach (string item in items)
            {
                Transform t = MenuItemParent.FindChild(item);
                if (t == null)
                {
                    continue;
                }
                t.gameObject.SetActive(false);
            }
            gameObject.transform.localPosition = new Vector3(-476, gameObject.transform.localPosition.y, gameObject.transform.localPosition.z);
            TweenPosition tweener = TweenPosition.Begin(gameObject, 0.1f, new Vector3(-848, gameObject.transform.localPosition.y, gameObject.transform.localPosition.z));

            while (tweener.enabled)
            {
                yield return(new WaitForEndOfFrame());
            }
            yield return(StartCoroutine(UIArcTab.RefreshToDstPosition(ArcTabGroup, button.GetComponent <UIArcTab>(), button.transform)));

            currentMainButton = null;
            if (IsDynamic)
            {
                if (onHide != null)
                {
                    onHide(items);
                }
            }
        }
示例#2
0
        private IEnumerator ShowSubMenu(UIButton button)
        {
            mIsAnimating = true;
            if (button == null)
            {
                yield break;
            }

            //hide
            if (currentMainButton != null)
            {
                yield return(StartCoroutine(HideSubMenu(currentMainButton)));
            }

            if (button == null)
            {
                yield break;
            }

            UIRankButton rankButton = button.GetComponent <UIRankButton>();

            if (rankButton != null)
            {
                rankButton.Active();
            }

            List <string> items = null;

            if (mRankTypeToSubMenu.TryGetValue(button.name, out items) == false)
            {
                mIsAnimating = false;
                yield break;
            }

            button.GetComponent <UIButton>().normalSprite = SpriteToggle;
            button.GetComponent <UIButton>().hoverSprite  = SpriteToggle;
            gameObject.transform.localPosition            = new Vector3(-848, gameObject.transform.localPosition.y, gameObject.transform.localPosition.z);
            TweenPosition tweener = TweenPosition.Begin(gameObject, 0.1f, new Vector3(-476, gameObject.transform.localPosition.y, gameObject.transform.localPosition.z));

            //                      TweenPosition tweener = TweenPosition.Begin(gameObject , 0.3f ,  new Vector3(-848 , gameObject.transform.localPosition.y , gameObject.transform.localPosition.z));
            while (tweener.enabled)
            {
                yield return(new WaitForEndOfFrame());
            }
            currentMainButton = button;

            //show sub
            if (currentMainButton == null)
            {
                yield break;
            }

            UIArcTab dstArcTab     = null;
            UIToggle toggleFirst   = null;
            UIToggle toggleDefault = null;

            if (items != null)
            {
                int index  = 0;
                int middle = items.Count / 2;
                foreach (string item in items)
                {
                    Transform t = MenuItemParent.FindChild(item);
                    if (t == null)
                    {
                        continue;
                    }
                    if (index == 0)
                    {
                        toggleFirst = t.GetComponent <UIToggle>();
                    }
                    if (item == DefaultToggleName)
                    {
                        toggleDefault = t.GetComponent <UIToggle>();
                    }
                    if (index == middle)
                    {
                        dstArcTab = t.gameObject.GetComponent <UIArcTab>();
                    }
                    t.position = currentMainButton.transform.position;
                    t.gameObject.SetActive(true);
                    index++;
                }
            }
            yield return(StartCoroutine(UIArcTab.RefreshToDstPosition(ArcTabGroup, dstArcTab, DestinationPosition)));

//            yield return StartCoroutine (UIArcTab.RefreshToDstPosition(ArcTabGroup, currentMainButton.GetComponent<UIArcTab>(), currentMainButton.transform));
            //restrict with in panel
            ScrollView.RestrictWithinBounds(true);
            mIsAnimating = false;
            if (toggleDefault != null)
            {
                toggleDefault.value = true;
                SwitchBranchButton(toggleDefault.name);
            }
            else
            {
                //set the frist
                if (toggleFirst != null)
                {
                    toggleFirst.value = true;
                }
                SwitchBranchButton(items[0]);
            }

            DefaultToggleName = "";
        }