Exemplo n.º 1
0
        /// <summary>
        /// Use this to create the UIFastList.
        /// Do NOT use AddUIComponent.
        /// I had to do that way because MonoBehaviors classes cannot be generic
        /// </summary>
        /// <typeparam name="T">The type of the row UI component</typeparam>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static UIFastList Create <T>(UIComponent parent)
            where T : UIPanel, IUIFastListRow
        {
            UIFastList list = parent.AddUIComponent <UIFastList>();

            list.m_rowType = typeof(T);
            return(list);
        }
Exemplo n.º 2
0
        private void SetupControls()
        {
            float offset = 40f;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.iconSprite = "IconAssetBuilding";
            m_title.title      = "Mesh Info " + MeshInfo.version;

            // Type DropDown
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = new Vector3(15f, offset + 5f);
            label.text             = "Type :";

            m_prefabType       = UIUtils.CreateDropDown(this);
            m_prefabType.width = 110;
            m_prefabType.AddItem("Building");
            m_prefabType.AddItem("Prop");
            m_prefabType.AddItem("Tree");
            m_prefabType.AddItem("Vehicle");
            m_prefabType.selectedIndex    = 0;
            m_prefabType.relativePosition = label.relativePosition + new Vector3(60f, 0f);

            m_prefabType.eventSelectedIndexChanged += (c, t) =>
            {
                m_prefabType.enabled = false;
                m_isSorted           = false;
                PopulateList();
                m_prefabType.enabled = true;
            };

            // Sorting DropDown
            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_prefabType.relativePosition + new Vector3(130f, 0f);
            label.text             = "Sort by :";

            m_sorting       = UIUtils.CreateDropDown(this);
            m_sorting.width = 125;
            m_sorting.AddItem("Name");
            m_sorting.AddItem("Triangles");
            m_sorting.AddItem("LOD Triangles");
            m_sorting.AddItem("Weight");
            m_sorting.AddItem("LOD Weight");
            m_sorting.AddItem("Texture");
            m_sorting.AddItem("LOD Texture");
            m_sorting.selectedIndex    = 0;
            m_sorting.relativePosition = label.relativePosition + new Vector3(60f, 0f);

            m_sorting.eventSelectedIndexChanged += (c, t) =>
            {
                m_sorting.enabled = false;
                m_isSorted        = false;
                PopulateList();
                m_sorting.enabled = true;
            };

            // Sorting direction
            m_sortDirection                  = AddUIComponent <UISprite>();
            m_sortDirection.atlas            = UIUtils.GetAtlas("Ingame");
            m_sortDirection.spriteName       = "IconUpArrow";
            m_sortDirection.relativePosition = m_sorting.relativePosition + new Vector3(130f, 0f);

            m_sortDirection.eventClick += (c, t) =>
            {
                m_sortDirection.flip = (m_sortDirection.flip == UISpriteFlip.None) ? UISpriteFlip.FlipVertical : UISpriteFlip.None;
                m_isSorted           = false;
                PopulateList();
            };

            // Search
            m_search                  = UIUtils.CreateTextField(this);
            m_search.width            = 150f;
            m_search.height           = 30f;
            m_search.padding          = new RectOffset(6, 6, 6, 6);
            m_search.relativePosition = new Vector3(width - m_search.width - 15f, offset + 5f);

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f);
            label.text             = "Search :";


            m_search.eventTextChanged += (c, t) => PopulateList();

            // Labels
            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.9f;
            label.text             = "Name";
            label.relativePosition = new Vector3(15f, offset + 50f);

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.9f;
            label.text             = "Texture";
            label.relativePosition = new Vector3(width - 135f, offset + 50f);

            UILabel label2 = AddUIComponent <UILabel>();

            label2.textScale        = 0.9f;
            label2.text             = "Weight";
            label2.relativePosition = label.relativePosition - new Vector3(125f, 0f);

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.9f;
            label.text             = "Triangles";
            label.relativePosition = label2.relativePosition - new Vector3(115f, 0f);

            // Item List
            m_itemList                  = UIFastList.Create <UIPrefabItem>(this);
            m_itemList.rowHeight        = 40f;
            m_itemList.backgroundSprite = "UnlockingPanel";
            m_itemList.width            = width - 10;
            m_itemList.height           = height - offset - 75;
            m_itemList.relativePosition = new Vector3(5f, offset + 70f);
        }