コード例 #1
0
ファイル: NToggleBinder.cs プロジェクト: lwx1010/2D_XProject
        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
ファイル: NSliderBinder.cs プロジェクト: lwx1010/2D_XProject
        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));
            }
        }
コード例 #3
0
        public override void StartBinding(GameObject mainObj, string args, string layerName)
        {
            try
            {
                UISprite background = LayerWordBinder.findChildComponent <UISprite>(mainObj, "background", "bg");
                background.type = UIBasicSprite.Type.Sliced;

                UISprite foreground = LayerWordBinder.findChildComponent <UISprite>(mainObj, "handle", "ha");
                foreground.transform.localPosition = Vector3.zero;
                foreground.width  = background.width - 10;
                foreground.height = background.height - 10;
                foreground.type   = UIBasicSprite.Type.Sliced;


                UIScrollBar scrollbar = LayerWordBinder.swapComponent <UIScrollBar>(mainObj);
                LayerWordBinder.NGUICopySprite(background.gameObject, mainObj, true);
                GameTools.AddWidgetCollider(mainObj);

                scrollbar.backgroundWidget = mainObj.GetComponent <UISprite>();
                scrollbar.foregroundWidget = foreground;
                scrollbar.value            = 0.1f;
                scrollbar.barSize          = 0.2f;

                GameTools.AddWidgetCollider(foreground.gameObject);
            }
            catch (Exception)
            {
                Debug.LogError(string.Format("[异常Scrollbar:{0}] 请检查是否存在(被隐藏)background和handle组! ", layerName));
            }
        }
コード例 #4
0
        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);
                    GameTools.AddWidgetCollider(childTrans.gameObject);
                }
            }

            //更新子结点的坐标
            NHelper.TransformOffset(g.transform, ogrinPos, false);
            g.transform.localPosition = ogrinPos;
        }
コード例 #5
0
        public override void StartBinding(GameObject mainObj, string args, string layerName)
        {
            try
            {
                UISprite bgTrans = LayerWordBinder.findChildComponent <UISprite>(mainObj, "background", "bg");
                bgTrans.type = UIBasicSprite.Type.Sliced;

                UILabel text = LayerWordBinder.findChildComponent <UILabel>(mainObj, "holder", "ho");
                text.transform.localPosition -= bgTrans.transform.localPosition;
                text.pivot = UIWidget.Pivot.Left;

                LayerWordBinder.NGUICopySprite(bgTrans.gameObject, mainObj, true);
                GameTools.AddWidgetCollider(mainObj);

                UIInput inputField = LayerWordBinder.swapComponent <UIInput>(mainObj);
                inputField.label = text;
            }
            catch (Exception)
            {
                Debug.LogError(string.Format("[异常InputField:{0}] 请检查是否存在(被隐藏)background和holder组! ", layerName));
            }
        }
コード例 #6
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;
                }

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