Home

Awesome

RosettaUI

Code-based UI library for development menu for Unity

public class ExampleSimple : MonoBehaviour
{
    public string stringValue;
    public float floatValue;
    public int intValue;
    public Color colorValue;

    
    void Start()
    {
        var root = GetComponent<RosettaUIRoot>();
        root.Build(CreateElement());
    }

    Element CreateElement()
    {
        return UI.Window(nameof(ExampleSimple),
            UI.Page(
                UI.Field(() => stringValue),
                UI.Slider(() => floatValue),
                UI.Row(
                    UI.Field(() => intValue),
                    UI.Button("+", () => intValue++),
                    UI.Button("-", () => intValue--)
                ),
                UI.Field(() => colorValue)
            )
        );
    }
}

<img src=Documentation~/simple.gif width=500px />

Installation

This package uses the scoped registry feature to resolve package dependencies.

Edit > ProjectSettings... > Package Manager > Scoped Registries

Enter the following and click the Save button.

"name": "fuqunaga",
"url": "https://registry.npmjs.com",
"scopes": [ "ga.fuquna" ]

Window > Package Manager

Select MyRegistries in Packages:

<img src="Documentation~/2022-04-12-17-40-26.png" width=35%>

Select RosettaUI - UI ToolKit and click the Install button

Input System(optional)

RosettaUI recommends using Input System.
See Tips.

Install according to the official documentation.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.5/manual/Installation.html

How to use

  1. Put Packages/RosettaUI - UIToolkit/RosettaUIRootUIToolkit.prefab in the Hierarchy
  2. Write code to generate Element instance
  3. Call RosettaUIRoot.Build(Element) to generate the actual UI ( Example )

Examples are available in this repository. I recommend downloading and checking it out.

Functions

UI.Field()

UI.Slider()

UI.MinMaxSlider()

UI.List()

Layout elements

And more!

Please check the Examples

Enviroment

PlatformSupport
Windows
MacMaybe(not tested)
LinuxMaybe(not tested)
IL2CPPSuspended
UI LibrarySupport
UI Toolkit
UGUISuspended
IMGUINot planned

Tips

Disable keyboard input when typing in UI

When using InputSystem, set RosettaUIRoot.disableKeyboardInputWhileUITyping=true (default) to disable keyboard input while typing in UI.

// false while typing in UI
if ( Keyboard.current[Key.A].wasPressedThisFrame )
{
    // do something
}

For LegacyInputSystem, refer to RosettaUIRoot.WillUseKeyInputAny().

if ( !RosettaUIRoot.WillUseKeyInputAny() && Input.GetKeyDown(KeyCode.A) )
{
    // do something
}

See also

PrefsGUI - Accessors and GUIs for persistent preference values using a JSON file