Пример #1
0
        protected void AddItemAt(Type itemType, object data, int index, bool doLayoutImmediately = true)
        {
            if (m_isExecutingCoroutine == true)
            {
                Log.Error("有尚未执行完毕的协程~~", this);
                return;
            }

            //要改成循环利用

            GameObject go = GameObjUtil.Instantiate(m_itemTemplate);

            go.transform.SetParent(this.transform);
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = Vector3.zero;
            go.SetActive(true);


            //BuildItem(go);
            KListItem item = ComponentUtil.EnsureComponent(go, itemType) as KListItem;

            item.Index = index;
            item.name  = GenerateItemName(index);
            AddItemEventListener(item);
            m_itemList.Insert(index, item);

            item.SetData(data);   //设置数据

            if (doLayoutImmediately)
            {
                RefreshAllItemLayout();
            }
        }
Пример #2
0
        protected override void __Initialize()
        {
            m_scrollable = true;

            m_maskTrans = GetChildComponent <RectTransform>("Image_mask");    //遮罩

            GameObject contentGo = GameObjUtil.FuzzySearchChild(m_maskTrans.gameObject, "content");

            m_contentTrans = contentGo.GetComponent <RectTransform>();
            m_contentTrans.anchoredPosition = Vector2.zero;
            m_contentTrans.sizeDelta        = new Vector2(m_maskTrans.rect.width, m_maskTrans.rect.height);

            m_scrollRect = ComponentUtil.EnsureComponent <ScrollRect>(this.gameObject);
            RefreshScrollRectSetting();
            m_scrollRect.viewport = m_maskTrans;
            m_scrollRect.content  = m_contentTrans;

            if (GetChild("Container_arrow") != null)
            {
                //有箭头
                m_scrollArrow = AddChildComponent <KScrollViewArrow>("Container_arrow");
            }

            m_scrollRect.onValueChanged.AddListener(OnInternalValueChanged);
        }
Пример #3
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);
    }
Пример #4
0
    //-------∽-★-∽------∽-★-∽--------∽-★-∽ListViewScroll∽-★-∽--------∽-★-∽------∽-★-∽--------//


    void ShowListViewScroll()
    {
        m_listViewScroll = ComponentUtil.EnsureComponent <KListViewScroll>(m_scrollViewItemList.gameObject);
        m_listViewScroll.itemViewType = typeof(Item1);
        m_listViewScroll.onDataChanged.AddListener(UpdateListItem2);

        LayoutParam param = m_listViewScroll.layoutParam;

        //param.padding = new Padding(20, 20, 20, 20);
        param.itemGap = new Vector2(10, 50);
        param.divNum  = 3;
        //param.dir = LayoutDirection.LeftToRight;

        List <int> datas = new List <int>();
        int        num   = 999;

        for (int i = 0; i < num; ++i)
        {
            datas.Add(i);
        }


        //m_listViewScroll.direction = KScrollView.ScrollDir.horizontal;

        m_listViewScroll.ShowList(datas);
    }
Пример #5
0
    //-------∽-★-∽------∽-★-∽--------∽-★-∽ListView∽-★-∽--------∽-★-∽------∽-★-∽--------//


    void ShowListView()
    {
        GameObject container = GameObjUtil.FindChild(m_scrollViewItemList.gameObject, "Image_mask/Container_content");

        List <int> datas = new List <int>();
        int        num   = 10;

        for (int i = 0; i < num; ++i)
        {
            datas.Add(i);
        }

        m_listView = ComponentUtil.EnsureComponent <KListView>(container);
        m_listView.itemViewType = typeof(Item1);
        m_listView.onDataChanged.AddListener(UpdateListItem);


        LayoutParam param = m_listView.layoutParam;

        //param.padding = new Padding(20, 20, 20, 20);
        param.itemGap = new Vector2(10, 50);
        //param.divNum = 2;


        m_listView.ShowList(datas);
    }
Пример #6
0
    //初始化人物位置
    public void Awake()
    {
        m_cameraTP = ComponentUtil.EnsureComponent <CameraTPerson>(m_camera.gameObject);
        m_cameraTP.SetTarget(transform);
        m_cameraTP.SetDefault(30, 30);

        ComponentUtil.EnsureComponent <CameraTPMouse>(m_camera.gameObject);
    }
Пример #7
0
        static List <int> __delList = new List <int>();    //需要删除的序号



        protected override void __Initialize()
        {
            m_scrollView = ComponentUtil.EnsureComponent <KScrollView>(this.gameObject);

            m_maskTrans = m_scrollView.maskTrans;

            m_contentTrans       = m_scrollView.contentTrans;
            m_contentSizeDefault = m_contentTrans.sizeDelta;      //content的默认尺寸(实际size不能比这个小)
            m_contentGo          = m_contentTrans.gameObject;

            m_itemTemp = GameObjUtil.FuzzySearchChild(m_contentGo, "item"); //只查找一层
            m_itemTemp.SetActive(false);                                    //隐藏掉模板

            //KListView a1 = gameObject.GetComponent<KListView>();
            //Component a2 = gameObject.GetComponent("mg.org.KUI.KListView");

            RectTransform rectTrans = m_itemTemp.GetComponent <RectTransform>();

            m_layoutParam.itemSize = rectTrans.sizeDelta;
            m_layoutParam.pivot    = rectTrans.pivot;
        }
Пример #8
0
        override protected void __Initialize()
        {
            GameObject arrowGo = GameObjUtil.FuzzySearchChild(gameObject, "arrow");

            if (arrowGo != null)
            {
                m_pageArrow = ComponentUtil.EnsureComponent <KScrollPageArrow> (arrowGo);
            }

            GameObject displayer = GameObjUtil.FuzzySearchChild(gameObject, "pager");

            if (displayer != null)
            {
                m_pageDisplayer = ComponentUtil.EnsureComponent <KScrollPageDisplayer>(displayer);
            }

            m_pageTrans = GetChildComponent <RectTransform>("Image_mask");

            GameObject contentGo = GameObjUtil.FuzzySearchChild(m_pageTrans.gameObject, "content");

            m_contentTrans = contentGo.GetComponent <RectTransform>();
        }