All Projects → plyoung → UIElements

plyoung / UIElements

Licence: Unlicense License
Various scripts related to Unity UI Toolkit (UIElements).

Programming Languages

C#
18002 projects
ShaderLab
938 projects

Projects that are alternatives of or similar to UIElements

ElementAnimationToolkit
A collection of Unity UIElements animation extension methods, new animated elements, and examples.
Stars: ✭ 51 (-30.14%)
Mutual labels:  uielements, uitoolkit
React-Tooltip-Controller
This is a feature-rich React component for controlling tooltips / pop-up menus
Stars: ✭ 21 (-71.23%)
Mutual labels:  tooltips
Mtgdb
Mtgdb.Gui - desktop app to search MTG cards and build decks
Stars: ✭ 46 (-36.99%)
Mutual labels:  tooltips
extensions
Angular Material Extensions Library.
Stars: ✭ 203 (+178.08%)
Mutual labels:  color-picker
javascript-color-gradient
Lightweight JavaScript library, used to generate an array of color gradients, between start and finish colors.
Stars: ✭ 54 (-26.03%)
Mutual labels:  color-picker
przm
🎨 A simple, yet feature rich color picker and manipulator
Stars: ✭ 19 (-73.97%)
Mutual labels:  color-picker
ColorPickView
🐾一个自定义的颜色选择view
Stars: ✭ 19 (-73.97%)
Mutual labels:  color-picker
flutter material color picker
Material color picker, you can customize colors. Selection in two step, first main color and after shades.
Stars: ✭ 68 (-6.85%)
Mutual labels:  color-picker
a-color-picker
A color picker for web app
Stars: ✭ 97 (+32.88%)
Mutual labels:  color-picker
aframe-colorwheel-component
A-Frame Colorwheel. Based on A-Painter and A-Frame Material 🎨🅰
Stars: ✭ 16 (-78.08%)
Mutual labels:  color-picker
epick
Color picker for creating harmonic color palettes that works on Linux, Windows, macOS and web.
Stars: ✭ 89 (+21.92%)
Mutual labels:  color-picker
Litrato
Android photo editing app with various filters and tools. Included advanced features like masking, histogram, color picker, EXIF viewer...
Stars: ✭ 54 (-26.03%)
Mutual labels:  color-picker
color-picker
A color picker app made in flutter
Stars: ✭ 46 (-36.99%)
Mutual labels:  color-picker
colorpicker
pure Angular.JS circle color-picker similar to google keep's color picker
Stars: ✭ 23 (-68.49%)
Mutual labels:  color-picker
ColorPicker
Customizable Color Picker control for WPF
Stars: ✭ 57 (-21.92%)
Mutual labels:  color-picker
blurr effect
An example of how to blurr the background for a widget in flutter.
Stars: ✭ 15 (-79.45%)
Mutual labels:  blur-backgrounds
Widget-Blur
This script for the Scriptable app creates widget backgrounds that appear to be transparent. You can also optionally emulate the light or dark blur effect used in the Batteries widget from Apple.
Stars: ✭ 113 (+54.79%)
Mutual labels:  blur-backgrounds
SpikeTip
Create effortless tooltips that breathe CSS! No Javascript. Just the good old CSS.
Stars: ✭ 26 (-64.38%)
Mutual labels:  tooltips
adobe-color-picker
The rebuilt color picker of Adobe scripting for PS,AI,AE and so on.
Stars: ✭ 37 (-49.32%)
Mutual labels:  color-picker
jquery-asColorPicker
ColorInput is a jQuery plugin used to show color picker for a input field.
Stars: ✭ 18 (-75.34%)
Mutual labels:  color-picker

UIElements

Various scripts related to Unity UI Toolkit (UIElements). These are not all plug-and-play but should serve as examples you can adopt for your own needs. Look in _misc for more stylesheets to help you get started with styling these components.

Color Field and Popup

Image of colorfield

A Color field and Color picker popup. You will need the popup and blur panel related scripts too if you want to use it as is.

The popup element should be at bottom of the document's root so that it can appear over other elements.

	...
    <Game.UI.ColorPopup name="color-popup" start-visible="false" />
</ui:UXML>

Insert the color field somewhere via UXML.

<Game.UI.ColorField name="grid-fill-color" label="Fill Colour" reset-label="\U0000f0e2" />

Link the color field with the color popup.

var colorPopup = root.Q<ColorPopup>("color-popup");
var gridFillColorField = root.Q<ColorField>("grid-fill-color");
gridFillColorField.ColorPopup = colorPopup;
gridFillColorField.ResetButtonPressed += () => gridFillColorField.value = Const.DefaultGridFillColor;

Popup panels

Image of popup Image of popup

Examples of how modal popup panels can be done. These will add a fullscreen element to prevent mouse clicks from reaching elements behind. Of course these need to be added to the root of a document and at the bottom so they appear over other elements.

    <Game.UI.PopupPanel name="settings-popup" class="settings-popup" start-visible="false">
        <ui:Instance template="SettingsPanel" class="settings-panel fill" />        
        <ui:Button text="\U0000f00d" name="popup-close-button" class="popup-close-button" />
    </Game.UI.PopupPanel>
	
    <Game.UI.PopupTextField name="popup-textfield" start-visible="false" />
    <Game.UI.PopupMessage name="popup-message" start-visible="false" />
</ui:UXML>

Game.UI.PopupPanel can be used to contain whatever you want to be in a popup panel (for example a Settings panel) or you can derive from it to create a more specialised popup, like the included PopupTextField, PopupMessage, and ColorPopup examples.

var popupMsg = root.Q<PopupMessage>("popup-message");
var popupEd = root.Q<PopupTextField>("popup-textfield");


popupMsg.Show("Lable", "message", "Close");

// 20 = how many characters allowed
popupEdit.Show("label", "message", "empty or text to set", 20,
	t => 
	{ 	// submit was pressed
		popupEdit.Hide();
		Debug.Log("Player entered: " + t);
	},
	() => 
	{	// cancel was pressed
		popupEdit.Hide();
	});

Tooltip

Image of Tooltip

UIElements does not have tooltip support at runtime. Here's some code to show how you can get it working.

You want to add something like this near the end of a UXML document. It needs to be at the end so that the tooltip will appear over other elements and not behind them.

  • Delay is how long it waits (ms) before it shows up.
  • Fade Time is how how quick or slow it fades in and out. 0 for no fade.

<Game.UI.Tooltip name="tooltip" picking-mode="Ignore" delay="500" fade-time="15" />

Now you need to bind this to all the buttons and other elements which can show a tooltip. You probably have some c# script where you are doing all kinds of bindings already so just put it in there.

var tooltip = root.Q<Tooltip>("tooltip");
var button = root.Q<Button>("some-button");
button.AddManipulator(new TooltipManipulator(tooltip));

The tooltip text comes from an element's tooltip attribute, for example ...

<ui:Button name="some-button" text="Button" tooltip="Settings" />

The tooltip will appear below the item by default but you can also hint to it to appear above, or to the left or right. Simply attach the following in front of the tooltip text to apply the hint. "L:" for left, "R:" for right, "T:" for above, and "B:" for below.

For example, to have the tooltip appear to the right-hand side of a button you would do this

<ui:Button name="some-button" text="Button" tooltip="R:Settings" />

AspectRatioPadding

Image of AspectRatioPadding

This element will add padding/margin to the left and right and update it such to push the "central" items to fit into a certain aspect ratio. So, if you choose to have a 4:3 ratio but this element is at 16:9 then padding is added to the left and right, same for when you design at 16:9 but the game is played on ultra wide. For anything at or below your design ratio the padding will be 0.

Sample, 4:3 design on 16:9 "display".

<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
    <Game.UI.AspectRatioPadding width="4" height="3" style="flex-direction: row; background-color: yellow;">
        <ui:VisualElement style="width:20px; background-color: red;" />
        <ui:VisualElement style="flex-grow:1; background-color: green;" />
        <ui:VisualElement style="width:20px; background-color: blue;" />
    </Game.UI.AspectRatioPadding>
</ui:UXML>

Blur/Glass Effect

Image of Blur

An example of doing a blur or milky glass effect. I am using URP but this could be adopted for other since a main part of this is a Rendertexture which provides the panel with the image information it needs.

You can insert the Blur Panel like any other element into UXML, or via C#.

<Game.UI.BlurPanel name="scene-toolbar" class="toolbar-back">

Then in C# you need to tell it about the blur image (render texture).

[SerializeField] private Texture blurTexture;
...
root.Q<BlurPanel>("scene-toolbar").SetImage(blurTexture);

If the Blur Panel is inside other elements that might move then you need to specify the moving parent too else the Blur will not update correctly.

panel.SetImage(blurTexture, someParentElement);

Shader information from https://github.com/ArneBezuijen/urp_kawase_UI_blur and https://github.com/sebastianhein/urp_kawase_blur and cleand up for this project.

Add the Blur Render Feature to the Forward Renderer Data via inspector. A Blur Render camera is used to render only a panel which uses a Blur material. Think of this camera as viewing the rendered world via a window (a plane using a blur shader material) and then rendering that to a texture. This texture is then used by the UI element. Note the culling mask and layer used by camera and plane object.

Image of Blur

Image of Blur

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].