NimGui stands for Nimble Immediate Mode General User Interface and is designed to be a replacement library to Unity’s runtime ImGui.
I have always found Unity’s runtime ImGui solution to be lackluster and displaying any kind of widgets on runtime is just too annoying to get it setup easily. Similarly, with Unity’s UGUI solution, there’s too much set up required in order to display some information or set up widgets to tweak values in your game. While Debug.Log is extremely useful, when debugging many pieces of information it can be difficult to search through and contextualize information.
This framework was designed with performance and simplicity in mind, so you can focus on drawing widgets to interact/display/debug information while developing your game.
Asset Store Link
Grab it on the Asset Store.
Features
-
Supports builtin render pipeline and URP
-
Built for Windows, Mac, Linux, & WebGL
-
Simple immediate static API to draw widgets
-
Draw Scopes via using pattern to begin and end areas (see the API Example below!)
-
Write GUI naturally in MonoBehaviour.Update() and DOTS’ SystemBase.OnUpdate()
-
High performance
-
Utilizes C# Job System & Burst Compiler
-
A library of built widgets
-
Box
-
Button
-
Collapsible Area
-
Dropdown Menu
-
Label
-
Line
-
Pane
-
Progress Bar
-
Toggle Button
-
Scroll Area
-
Slider (float & int)
Limitations
- Static APIs cannot be called from separate threads simultaneously
- Static APIs cannot be called from LateUpdate as this will throw a warning in the rendered UI
- Static APIs can be called from FixedUpdate but will only appear for a frame as UI gets updated every frame and FixedUpdate does not
- Does not support the new InputSystem yet
Performance
NImGui can process 250 widgets in 1 millisecond on the main thread in the Editor. On a build, you can expect it to take 0.4 millisecond instead. This is achieved via multithreading using Unity’s Job System and Burst Compiler.
These stats were recorded on an Intel Core i7-7700HQ @ 2.8 GHz. More stats will be collected across varying hardware and operating systems.
Versions Supported
- Unity 2020.3 LTS
- Unity 2021.1
- Unity 2021.2
Dependencies
- Unity Collections
- Unity Jobs
API Style
The API follows an immediate mode style. Here is an example of the API you would be writing:
using (ImPane pane = new ImPane("Sample Pane", new float2(500), new float2(500))) {
if (pane.IsVisible) {
var t = Mathf.PingPong(Time.time * 0.5f, 1f);
ImGui.Label("Here's an example of drawing panes and widgets");
ImGui.ProgressBar(t);
ImGui.Dropdown("Dropdown", options);
if (ImGui.Button("Click me to toggle")) {
showMsg = !showMsg;
}
if (showMsg) {
ImGui.Label("Message shown!");
}
ImGui.Slider("Int Slider", 0, 10);
using (new ImScrollArea("Scroll Area")) {
using (ImCollapsibleArea group = new ImCollapsibleArea("Group")) {
if (group.IsVisible) {
if (ImGui.Toggle("Show Box")) {
ImGui.Box(300, Color.red, true);
}
}
}
}
}
}
This would produce an output like so:
personalsatisfiedcutworm
Demo
The demo can be tested at the following link on itch.io:
__**https://initialprefabs.itch.io/nimgui**__
Immediate Roadmap
The first version of NImGui is expected to be released at the end of 2021/early 2022 as there are few things that I need to finish such as:
-
escape characters support in the Label API (for new line and tabs)
-
Textfield API
-
Support Unity’s new Input System
-
a browsable API / docs website
-
LateUpdate support for drawing widgets
-
One draw call UI (right now each widget drawn will issue between 1 to a few draw calls)
-
This may also allow me to shift away from using TextMeshPro materials as it is a current dependency
Longer Term Goals
- RTL language support
- Complex text layout support (e.g. support for Arabic, Khmer, Thai, etc)
- Command Buffer like API for dynamic widgets and panes & multithreading support
- Stateful FixedUpdate support (e.g if you need to debug netcode which will run on a Fixed Timestep, it will make sense to store and display the information until the next Fixed Timestep)
Initial feedback and questions are welcomed! Feel free to comment in this thread below.