QuickStart
Displaying Your First Widget
Create a new MonoBehaviour called ImGuiExample.cs in your project. Unlike Unity's ImGui,
there is no reliance on implementing a separate callback function like OnGui()
, you can
call all ImGui functions in Update
.
⚠️ While it is possible to call ImGui in
FixedUpdate
, it will only appear for a single frame until the next time FixedUpdate is called. This is the correct behaviour of how ImGui works, don't fight me on this. If you need to draw duringFixedUpdate
, cache the data you need and pass that data to theUpdate
loop instead.
Add the following snippet:
using InitialPrefabs.NimGui;
public class ImGuiExample : MonoBehaviour {
void Update() {
ImGui.Label("This is an example label.");
ImGui.SameLine();
var t = 0.5f * Mathf.Cos(Time.time * 0.5f + Mathf.PI) + 0.5f;
ImGui.ProgressBar(t);
}
}
This will create a label displayed in the top left corner of the screen with a progress bar.
And that's it! Getting started with NimGui
is pretty much calling a bunch of static APIs
to draw your widgets. We strongly recommend looking at the NimGuiDemo.cs
file as a point
of reference.