/// <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); }
private void SetupControls() { float offset = 40f; m_title = AddUIComponent <UITitleBar>(); m_title.iconSprite = "IconAssetBuilding"; m_title.title = "Mayoral City Service Info " + MCSI.version; _tabstrip = UIUtils.CreateTabStrip(this); _tabstrip.tabPages = UIUtils.CreateTabContainer(this); _templateButton = UIUtils.CreateTabButton(this); for (int i = 0; i < kServices.Length; i++) { SpawnSubEntry(_tabstrip, kServices[i]); } _tabstrip.relativePosition = new Vector3(15f, offset); _tabstrip.eventSelectedIndexChanged += (c, t) => PopulateList(); Destroy(_templateButton); /* * // 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 = GetUIView().defaultAtlas; * 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); UILabel 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 = Locale.Get("EXTENDED_PUBLIC_TRANSPORT_UI_ITEM_1"); label.relativePosition = new Vector3(15f, offset + 45f); label = AddUIComponent <UILabel>(); label.textScale = 0.9f; label.text = Locale.Get("TUTORIAL_ADVISER_TITLE", "District"); label.relativePosition = new Vector3(550f, offset + 45f); label = AddUIComponent <UILabel>(); label.textScale = 0.9f; label.text = Locale.Get("CAMPUSPANEL_VARSITYSPORTS_UPKEEP"); label.relativePosition = new Vector3(675f, offset + 45f); // Item List m_itemList = UIFastList.Create <UIPrefabItem>(this); m_itemList.RowHeight = 40f; m_itemList.CanSelect = true; m_itemList.BackgroundSprite = "UnlockingPanel"; m_itemList.width = width - 10; m_itemList.height = height - offset - 75; m_itemList.relativePosition = new Vector3(5f, offset + 70f); }