This is pack of functions and widgets of UI elements for plugin developers. It has Demo, so you can test all its features runtime (add it as plugin to any place).
I was inspired of CustomUI by 14mhz and since I am using custom functions in my plugins to add VaM's default UI elements, I made my own collection of functions and helpers to use it myself and share.
It is started as "new tab widget with rotated tabs" but finished with combination of all my custom stuff which work together.
You can inspire, modify, adapt, copy, share and whatever you want if you need it. I've tested new classes in unity editor and realtime, so all this should work fine without jitters and lags.
Not for dependency, extract it and use as source code, make changes as needed.
Demo has my own workflow for scripting and useful functions for safely load resources and use it in UI
StandardUI Demo
TabWidget Demo
You can add default VaM's UI elements:
- Spacer
- Button
- Text
- Toggle
- Slider
- Popup
- ScrollablePopup
- FilterablePopup
- ColorPicker (HSV)
- TextTitle - Text but with big title using rich text.
- TextTitleShrinked - Text but with big title using rich text, a bit smaller one.
- SliderInt - default slider but with integer params for default value, min/max, and integer callback.
- SliderSmall - modified default slider to be one line with height of button and without range buttons.
- SliderSmallInt - like SliderInt and SliderSmall.
- HotkeyPopup - predefined custom popup with all possible hotkeys from KeyCode enum.
- ColorPicker (RGB) - default color picker but with Color callback.
- ColorPicker (HSVA) - modified color picker, using custom JSONStorableColorAlpha to edit and store alpha value in Color.
- ColorPicker (RGBA) - modified HSVA color picker with Color callback.
- TabWidget - complex custom widget which holds many "pages" and show only one of them. Current page can be chaged by clicking on header's tabs.
- TabStyle - since TabWidget has a lot of params to change visual look, and you likely want all TabWidgets look the same, better to hold all params in one style class. Modifying it you need to call InvokeUpdated() function to update all linked TabWidgets.
TabWidget properties:
- currentIndex - current visible page. Can be -1, so only header and empty ContentSelector will be visible.
- useMaxWidthOfAllItems - during layout calculation, the ContentSelector width is set to the maximum width of all pages. Not really useful since almost all VaM's ui using vertical layouts.
- useMaxHeightOfAllItems - during layout calculation, the ContentSelector height is set to the maximum height of all pages.
- notSelectedColor - color of widget if current index == -1.
- headerSide - TabHeader can be in 4 possible places: Top, Right, Bottom, Left.
- tabsExpanded - when tabs fit in available space, they will be stretched to look more beautiful.
- tabsRotated - tabs can be rotated by 90 degrees.
- tabsScrollStep - the distance the tabs will be moved when you click the arrow buttons.
- tabsAlign - when tabs fit in available space, they will be aligned to the side.
- tabStyle - style of TabWidget and all it's items.
Fixes:
- Popup overlay fix - sometimes opened popup menu is showing behind next UI elements (and inside current plugin borders), so now it will be rendered above any UI, even VaM's main menu and other stuff.
- ColorPicker cursor fix - sometimes cursor of current color has wrong position, I've added component which recalculating position when RectTransform changing it's size.
Useful custom classes which can be used independently:
- ContentSelector - holds many panels and show only one of them. Hiding, not disabling them. Calculating layouts for them and can use their maximal sizes for itself.
- TabHeader - header with tabs.
- HorizontalSwapVerticalLayoutGroup - layout can be switched from horizontal to vertical arrangement in runtime.
- ImageAspectRatio - derived class from Image with fixed desired height and calculated width keeping aspect ratio.
- SingleLayoutGroup - lightweight layout for single element.
- SingleRotateableLayoutGroup - complex layout with ability to rotate it's single content by 90 degrees. It is recalculating child hierarchy sizes and positions twice, be careful.
- TabWidgetEnums - example of enum imitation since VaM scripts cannot use new created enums.
- UITriangleArrow - simple graphics element to draw fixed size arrow.