Exemplo n.º 1
0
        public static CTabBar CreateTabBar(int x, int y, Transform parent, string[] items, int itemW, int itemH, int depth, int offsetX = 0)
        {
            GameObject obj = UnityEngine.Object.Instantiate(FuncUtil.GetUIAssetByPath(TABBAR_PATH)) as GameObject;

            if (obj == null)
            {
                return(null);
            }
            obj.transform.parent        = parent;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = new Vector3(x, y, 0);
            CTabBar box         = obj.GetComponent <CTabBar>();
            var     defaultItem = DisplayUtil.GetChildByName(obj.transform, "Tab0");

            if (defaultItem != null)
            {
                GameObject.DestroyImmediate(defaultItem.gameObject);
            }
            box.RemoveItems();
            for (var i = 0; i < items.Length; i++)
            {
                var btn = CreateTabBarBtn(i * itemW + offsetX, 0, obj.transform, items[i], itemW, itemH, depth);
                btn.name = "Tab" + i;
            }
            box.Start();
            return(box);
        }
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
 public Transform GetChildByName(string name)
 {
     return(DisplayUtil.GetChildByName(tran, name));
 }