Example #1
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));
            }
        }
Example #2
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));
            }
        }
        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);
                NGUITools.AddWidgetCollider(mainObj);

                UIInput inputField = LayerWordBinder.swapComponent <UIInput>(mainObj);
                inputField.label = text;
            }
            catch (Exception)
            {
                Debug.LogError(string.Format("[异常InputField:{0}] 请检查是否存在(被隐藏)background和holder组! ", layerName));
            }
        }