示例#1
0
    public TestPop4()
    {
        m_popId    = POP_ID.TEST_POP_4;
        m_layerIdx = POP_LAYER_IDX.LAYER_POP_1;

        ShowGameObject();

        //
        m_btnOk    = GetChildByName <KButton>("Button_Ok", true);
        m_btnClose = GetChildByName <KButton>("Button_Close", true);

        m_panel = GameObjUtil.GetParent(m_btnOk.gameObject);

        //
        m_inputName      = GetChildByName <KInputField>("Input_name", true);
        m_labelTestInput = GetChildByName <KText>("Label_testInput", true);
        //
        m_tgl_1      = GetChildByName <KToggle>("Toggle_position1", true);
        m_labelTgl_1 = GetChildByName <KText>(m_tgl_1.gameObject, "Label_Text", true);
        m_tglGroup_1 = GetChildByName <KToggleGroup>("ToggleGroup_a1", true);
        //
        m_sliderSchedule = GetChildByName <KSlider>("Slider_Schedule1", true);
        m_labelSchedule  = GetChildByName <KText>("Label_testSilder", true);
        //
        m_barLoading = GetChildByName <KProgressBar>("ProgressBar_loading", true);
        //
        m_icon = GetChildByName <KImage>("Image_sharedAnchor", true);
        //
        m_scrollView = GetChildByName <KScrollView>("ScrollView_GuildList", true);
        m_listView   = ComponentUtil.EnsureComponent <KListViewScroll>(m_scrollView.gameObject);
    }
示例#2
0
    public TestKUIPop3()
    {
        m_popId    = POP_ID.TEST_KUI_3;
        m_layerIdx = POP_LAYER_IDX.LAYER_POP_1;

        ShowGameObject();

        m_toggle1 = GetChildByName <KToggle>("Toggle_position1", true);
        m_toggle1.needReqChange = true;

        m_toggleGroup1 = GetChildByName <KToggleGroup>("ToggleGroup_1", true);
        //m_toggleGroup1.allowMultiple = true;
        //m_toggleGroup1.needReqChange = true;
        //m_toggleGroup1.allowSwitchOff = true;

        m_inputName = GetChildByName <KInputField>("Input_name", true);


        m_buttonAnnounce = GetChildByName <KButton>("Button_SystemAnnounce", true);
        m_buttonClose    = GetChildByName <KButton>("Button_Close", true);


        m_barExp          = GetChildByName <KProgressBar>("ProgressBar_EXP", true);
        m_sliderSchedule1 = GetChildByName <KSlider>("Slider_Schedule1", true);

        m_icon1 = GetChildByName <KImage>("Image_Icon1", true);


        m_scrollViewItemList = GetChildByName <KScrollView>("ScrollView_ItemList", true);
    }
示例#3
0
        private void CenterFitChildren(GameObject go)
        {
            KInputField input       = go.GetComponent <KInputField>();
            GameObject  placeholder = input.placeholder.gameObject;
            GameObject  inputtext   = input.textComponent.gameObject;

            var parentTransform      = go.GetComponent <RectTransform>(); //把inputtext变成这个尺寸, 然后居中对齐
            var placeholderTransform = placeholder.GetComponent <RectTransform>();
            var inputtextTransform   = inputtext.GetComponent <RectTransform>();

            //placeholderTransform.sizeDelta = parentTransform.rect.size;
            //placeholderTransform.anchoredPosition = new Vector2(placeholderTransform.anchoredPosition.x, 0);

            inputtextTransform.sizeDelta = parentTransform.rect.size;
            //inputtextTransform.anchoredPosition = new Vector2(inputtextTransform.sizeDelta.x * 0.5f, -inputtextTransform.sizeDelta.y * 0.5f);
            KuiUtil.SetAnchorSmart(inputtextTransform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f));
            inputtextTransform.anchoredPosition = new Vector2(-inputtextTransform.sizeDelta.x * 0.5f, inputtextTransform.sizeDelta.y * 0.5f);
        }
示例#4
0
        protected void AddComponent(GameObject go)
        {
            KText[] textList   = go.GetComponentsInChildren <KText>();
            KText   text       = null;
            KText   textHolder = null;

            foreach (KText t in textList)
            {
                if (t.name.ToLower().Contains("textholder"))
                {
                    textHolder = t;
                }
                else
                {
                    text = t;
                }
            }

            //TextWrapper text = go.GetComponentInChildren<TextWrapper>();

            RectTransform textRect = text.GetComponent <RectTransform>();

            //textRect.pivot = new Vector2(0.5f, 0.5f);
            //textRect.anchoredPosition = new Vector2(textRect.sizeDelta.x * 0.5f, -textRect.sizeDelta.y * 0.5f);   //为什么要调整位置?
            text.supportRichText = false;

            KInputField input = go.AddComponent <KInputField>();

            input.textComponent = text; //主体文本

            if (textHolder != null)
            {
                input.placeholder = textHolder; //占位文本
            }

            if (text.text == "{0}")
            {
                input.text = "";
            }
            else
            {
                input.text = text.text;
            }
        }