-
Announcement
-
Simtropolis Returns! 05/26/2026
See here for details about our site recovery efforts.
-
Search the Community
Showing results for tags 'dropdown'.
Found 1 result
-
For a while I am facing a problem with UI Dropdowns. Simply, if there are too many items many of them will be neither visible nor accessible. When I implemented the UI dropdown I copied it from other mods (Parallel road tool, originally probably from CimTools) so I looked for inspiration there. But the parallel road mod seems to be facing the exact same problem - many items are inaccessible. I even found there something called something like "TextFieldDropdown" suggesting that there would be a text field for searching thru the list, but it was not implemented. When looking at the code of UIDropDown, I found this interesting field - public UIScrollbar listScrollbar { ... } Adding a scrollbar to the dropdown selection list would solve all my problems, but I didn't figure out how to do it. I looked in many places in the game, but didn't find a single dropdown which would have a scrollbar! So I can't copy it from anywhere. This is +/- where I am at with my code: public class UINetInfoDropDown : UIDropDown { private NetInfo[] m_netInfos; private SortedDictionary<string, NetInfo> m_dictionary; public UINetInfoDropDown() { atlas = ResourceLoader.GetAtlas("Ingame"); size = new Vector2(90f, 30f); listBackground = "GenericPanelLight"; itemHeight = 25; itemHover = "ListItemHover"; itemHighlight = "ListItemHighlight"; normalBgSprite = "ButtonMenu"; disabledBgSprite = "ButtonMenuDisabled"; hoveredBgSprite = "ButtonMenuHovered"; focusedBgSprite = "ButtonMenu"; listWidth = 90; listHeight = 1000; listPosition = UIDropDown.PopupListPosition.Below; clampListToScreen = true; foregroundSpriteMode = UIForegroundSpriteMode.Stretch; popupColor = new Color32(45, 52, 61, 255); popupTextColor = new Color32(170, 170, 170, 255); zOrder = 1; textScale = 0.8f; verticalAlignment = UIVerticalAlignment.Middle; horizontalAlignment = UIHorizontalAlignment.Left; selectedIndex = 0; textFieldPadding = new RectOffset(8, 0, 8, 0); itemPadding = new RectOffset(14, 0, 8, 0); UIButton button = AddUIComponent<UIButton>(); triggerButton = button; button.atlas = ResourceLoader.GetAtlas("Ingame"); button.text = ""; button.size = size; button.relativePosition = new Vector3(0f, 0f); button.textVerticalAlignment = UIVerticalAlignment.Middle; button.textHorizontalAlignment = UIHorizontalAlignment.Left; button.normalFgSprite = "IconDownArrow"; button.hoveredFgSprite = "IconDownArrowHovered"; button.pressedFgSprite = "IconDownArrowPressed"; button.focusedFgSprite = "IconDownArrowFocused"; button.disabledFgSprite = "IconDownArrowDisabled"; button.foregroundSpriteMode = UIForegroundSpriteMode.Fill; button.horizontalAlignment = UIHorizontalAlignment.Right; button.verticalAlignment = UIVerticalAlignment.Middle; button.zOrder = 0; button.textScale = 0.8f; // Does not work - UIScrollbar sbar = AddUIComponent<UIScrollbar>(); listScrollbar = sbar; sbar.width = 20; sbar.height = 1000; sbar.scrollSize = 40; sbar.relativePosition = new Vector2(0, height); eventSizeChanged += new PropertyChangedEventHandler<Vector2>((c, t) => { button.size = t; listWidth = (int)t.x; }); Populate(); } ... } When I open the scene explorer there is some kind of item in the place where the scrollbar should be, but nothing is visible. Maybe the problem is with setting the sprites; I don't know. I would appreciate any help!

