[C#] How can I make filterless small ComboBox ? (Done)

Use CreateScollablePopup, not CreatePopup or CreateFilterablePopup.

This will result in a popup that has the scrollbar in the options panel, but also a horizontal scrollbar above the selected option:

1734021345611.png


If you want to get rid of the horizontal scrollbar, just disable that game object:

C#:
var uiDynamic = CreateScrollablePopup...
var sliderTransform = uiDynamic.transform.Find("Slider");
sliderTransform.gameObject.SetActive(false);
// OR destroy it: UnityEngine.Object.Destroy(sliderTransform.gameObject);
1734021467974.png


You can further resize things a bit to make it look similar to the standard popup created with CreatePopup:
C#:
var layoutElement = uiDynamic.GetComponent<LayoutElement>();
layoutElement.minHeight = 60;
layoutElement.preferredHeight = 60;

var buttonRectTransform = (RectTransform) uiDynamic.transform.Find("Button");
buttonRectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 60);

var popupPanelRectTransform = (RectTransform) uiDynamic.transform.Find("PopupPanel");
var pos = popupPanelRectTransform.anchoredPosition;
popupPanelRectTransform.anchoredPosition = new Vector2(pos.x, pos.y + 15);
1734022012480.png


Hope that helps.
 
Just as a note, in some situations it can help to just add a Spacer element to the bottom of your UI.
C#:
public static UIDynamic SetupSpacer(MVRScript script, float height, bool rightSide)
{
    UIDynamic spacer = script.CreateSpacer(rightSide);
    spacer.height = height;
    return spacer;
}
 
I think, might need upside/downside options for popup as arguments ...
Well, lets say your Popup is placed right at the bottom, maybe the last element. In that case even with scrollbar there might not be enough space. Hence adding a spacer as the last UI element just allows you to scroll the plugin UI further down. Just a simple workaround for VaM's UI limitations.
 
Last edited:
Back
Top Bottom