示例#1
0
        public override void StartBinding(GameObject gObj, string args, string layerName)
        {
            try
            {
                UIToggle toggleCom = LayerWordBinder.swapComponent <UIToggle>(gObj);
                toggleCom.@group = 1;

                Transform bgTrans = LayerWordBinder.findChildComponent <Transform>(gObj, "background", "bg");
                UIWidget  bgWidge = bgTrans.GetComponent <UIWidget>();

                Transform imgMarkTrans = LayerWordBinder.findChildComponent <Transform>(gObj, "checkmark", "cm");
                UIWidget  imgMark      = LayerWordBinder.swapComponent <UIWidget>(imgMarkTrans.gameObject);
                imgMark.depth = bgWidge.depth + 1;
                imgMark.SetDimensions(bgWidge.width, bgWidge.height);

                toggleCom.activeSprite = imgMark;

                Vector3 orginPos = bgTrans.localPosition;
                NHelper.TransformOffsetParent(gObj.transform, bgTrans, orginPos);
                gObj.transform.localPosition = orginPos;

                GameTools.AddWidgetCollider(gObj);
            }
            catch (Exception)
            {
                Debug.LogError(string.Format("[异常Toggle:{0}] 请检查是否存在(被隐藏)background组! ", layerName));
            }
        }
示例#2
0
        public override void StartBinding(GameObject mainObj, string args, string layerName)
        {
            try
            {
                UISlider slider = LayerWordBinder.swapComponent <UISlider>(mainObj);

                UISprite imgBg = LayerWordBinder.findChildComponent <UISprite>(mainObj, "background", "bg");
                imgBg.type = UIBasicSprite.Type.Sliced;

                UISprite imgFill = LayerWordBinder.findChildComponent <UISprite>(mainObj, "fill", "fl");
                imgFill.type            = UIBasicSprite.Type.Sliced;
                slider.foregroundWidget = imgFill;

                UISprite imgHandle = LayerWordBinder.findChildComponent <UISprite>(mainObj, "handle", "ha");
                if (imgHandle != null)
                {
                    slider.thumb = imgHandle.transform;
                    slider.thumb.localPosition -= imgBg.transform.localPosition;
                    imgFill.width = imgBg.width - imgHandle.width;
                }

                Vector3 offset = imgBg.transform.localPosition;
                NHelper.TransformOffset(mainObj.transform, offset, true);
                LayerWordBinder.NGUICopySprite(imgBg.gameObject, mainObj, true);
                mainObj.transform.localPosition = offset;

                slider.backgroundWidget = mainObj.GetComponent <UIWidget>();
                slider.value            = 0.2f;
                GameTools.AddWidgetCollider(mainObj);
            }
            catch (Exception)
            {
                Debug.LogError(string.Format("[异常Slider:{0}] 请检查是否存在(被隐藏)background和fill组! ", layerName));
            }
        }
        public override void ExitBinding(GameObject g, string args, string layerName)
        {
            foreach (Transform childTrans in g.transform)
            {
                if (childTrans.name.StartsWith("item"))
                {
                    reducePosition(childTrans);
                    LayerWordBinder.swapComponent <UIDragScrollView>(childTrans.gameObject);
                    NGUITools.AddWidgetCollider(childTrans.gameObject);
                }
            }

            //更新子结点的坐标
            NHelper.TransformOffset(g.transform, ogrinPos, false);
            g.transform.localPosition = ogrinPos;
        }
示例#4
0
        public override void StartBinding(GameObject gObj, string args, string layerName)
        {
            try
            {
                //需求添加,用于导出Lua识别类型
                UIButton btn = LayerWordBinder.swapComponent <UIButton>(gObj);
                btn.enabled = false;

                UIButtonScale button = LayerWordBinder.swapComponent <UIButtonScale>(gObj);
                LayerWordBinder.swapComponent <UIEventListener>(gObj);
                button.pressed = Vector3.one * 0.8f;
                //            UIButton button = LayerWordBinder.swapComponent<UIButton>(gObj);
                //            button.pressed = Color.white;
                //            button.hover = Color.white;

                UISprite imgBtn = gObj.GetComponent <UISprite>();
                if (imgBtn == null)
                {
                    imgBtn = LayerWordBinder.findChildComponent <UISprite>(gObj, "background", "bg");
                }

                if (imgBtn != null)
                {
                    //button.tweenTarget = imgBtn.gameObject;
                    Vector3 originPos = imgBtn.transform.localPosition;
                    NHelper.TransformOffset(gObj.transform, imgBtn.transform.localPosition, true);
                    gObj.transform.localPosition = originPos;
                }

                NGUITools.AddWidgetCollider(gObj);
            }
            catch (Exception)
            {
                Debug.LogError(string.Format("[异常Button:{0}] 请检查是否存在(被隐藏)background组! ", layerName));
            }
        }