Exemple #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);
    }
Exemple #2
0
    void OnTglGroupValue(KToggleGroup tglGroup_, int idx_, bool b_)
    {
        KToggle child = tglGroup_.GetToggle(idx_);
        KText   label = GetChildByName <KText>(child.gameObject, "Label_Text");

        label.text = b_ ? "选中" : "没选中";
    }
Exemple #3
0
    int m_clickCntMax = 3;  //关闭需要的点击次数

    public PopErrorReport()
    {
        m_popId    = POP_ID.ERROR_REPORT;
        m_layerIdx = POP_LAYER_IDX.LAYER_TOP;

        ShowGameObject();


        m_btn  = GetChildByName <KButton>("Container_ErrorReport/Container_Panel/Button_Center");
        m_text = GameObjUtil.FindChlid <KText>(m_btn.gameObject, "Label_Text");
    }
Exemple #4
0
    public LoadingView1()
    {
        m_popId    = POP_ID.LOADING_1;
        m_layerIdx = POP_LAYER_IDX.LAYER_LOADING;
        m_lifeType = POP_LIFE.FOREVER;

        ShowGameObject();

        m_barLoading       = GetChildByName <KProgressBar>("ProgressBar_Load", true);
        m_barLoading.value = 0;

        m_txtPercent = GetChildByName <KText>("Label_Percent", true);
        m_txtTips    = GetChildByName <KText>("Label_Tips", true);
    }
Exemple #5
0
    void UpdateListItem(GameObject item_, int index_, object data_)
    {
        GameObject select         = GetChildByName(item_, "Image_bg/select");
        GameObject normal         = GetChildByName(item_, "Image_bg/normal1");
        KText      labelName      = GetChildByName <KText>(item_, "Label_Name");
        KText      labelWinNum    = GetChildByName <KText>(item_, "Label_WinNum");
        KText      labelMemberNum = GetChildByName <KText>(item_, "Label_MemberNum");

        bool b = (index_ % 2) == 0;

        normal.SetActive(b);
        select.SetActive(!b);

        //index_ += 1;
        labelName.text   = "路人甲" + index_;
        labelWinNum.text = index_.ToString();
        labelWinNum.text = 999 + "人";
    }
Exemple #6
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;
            }
        }
Exemple #7
0
        protected virtual void AddTextComponent(GameObject go, JsonData stateData)
        {
            KText text = go.AddComponent <KText>();

            text.supportRichText = true;
            JsonData formatData = stateData["format"];

            text.color    = GetColor((string)formatData["color"], 100);
            text.font     = KAssetManager.GetFont((string)formatData["font"]);
            text.fontSize = (int)formatData["size"];
            text.text     = (string)stateData["content"];
            text.material = KAssetManager.GetFontMaterial();
            if (text.text == "{0}")
            {
                text.text = "?";
            }
            //单行文本默认值,超出文本范围不显示
            text.horizontalOverflow = HorizontalWrapMode.Overflow;  //改为自动增长
            text.verticalOverflow   = VerticalWrapMode.Truncate;
            //多行文本垂直方向超出范围仍然显示
            float h = 0.0f;

            if (stateData["height"].IsInt)
            {
                h = (float)(int)stateData["height"];
            }
            else
            {
                h = (float)(double)stateData["height"];
            }
            bool isMutilple = IsMutilpleLine(h, (int)formatData["size"]); //多行

            if (isMutilple)
            {
                text.horizontalOverflow = HorizontalWrapMode.Wrap;
                text.verticalOverflow   = VerticalWrapMode.Overflow;
            }
            else//单行,检查overflow是否设置
            {
                if (HasParam(stateData, PATTERN_OVERFLOW) == true)
                {
                    text.horizontalOverflow = HorizontalWrapMode.Overflow;  //水平多行
                }
                else if (HasParam(stateData, PATTERN_WRAP) == true)
                {
                    text.horizontalOverflow = HorizontalWrapMode.Wrap;  //超出文本范围不显示
                }

                if (HasParam(stateData, PATTERN_OVERFLOW_V) == true)
                {
                    text.verticalOverflow = VerticalWrapMode.Overflow;      //垂直多行
                    //如果直接指定垂直方向overflow,那横向将自动设为换行
                    text.horizontalOverflow = HorizontalWrapMode.Wrap;
                }
            }
            if (stateData.Keys.Contains("langId") == true)  //语言包,暂时没用
            {
                text.langId = (int)stateData["langId"];
            }
            text.alignment = TextAnchor.UpperLeft;  //文本对齐方式
            if (stateData.Keys.Contains(PATTERN_ALIGNMENT) == true)
            {
                string alignment = (string)stateData[PATTERN_ALIGNMENT];
                text.alignment = (TextAnchor)Enum.Parse(typeof(TextAnchor), alignment, true);
            }
            text.lineSpacing = 1.0f;
            if (stateData.Keys.Contains("lineSpacing") == true)   //行距
            {
                text.lineSpacing = float.Parse((string)stateData["lineSpacing"]);
            }
            text.resizeTextForBestFit = GetBestFitParam(stateData); //缩放文本框来适应文本框
            int bold = (int)formatData["bold"];                     //粗体

            text.fontStyle = (bold == 1) ? FontStyle.Bold : FontStyle.Normal;
            text.fontStyle = GetFontStyleParam(stateData); //覆盖了上面。。
            AddUnderline(go, stateData);                   //添加下划线
            AddGradientEffect(go, stateData);
            AddStrokeEffect(go, stateData);                //添加描边
            AddShadowEffect(go, stateData);                //添加阴影
            if (isMutilple == false)
            {
                SetPreferredSize(go);
            }
            if (go.name == STATE_DISABLE)
            {
                text.grey = true;   //置灰
            }
        }
Exemple #8
0
        protected override void __ShowGameObject()
        {
            base.__ShowGameObject();

            m_label = GetChildByName <KText>("Label_Text");
        }