Details

Last Updated
2 months ago
First Uploaded
2 months ago
Downloads
78
Likes
0
Size
16KB
Dependency string
xiaoxiao921-OverlayDearImGui_BepInEx5-2.0.0
Dependants

Categories

OverlayDearImGui.BepInEx5

Creates an overlay window that renders Dear ImGui over the process of your choice.

Does not work when the target application is exclusively full-screen.

Usage

The keybind for bringing up the cursor for interaction is by default the Insert key, which can be modified in the configuration file.

Mod Developers

Download this package and the OverlayDearImGui.Shared dependency. Add a reference to ImGui.NET.dll (from Shared) and OverlayDearImGui.BepInEx5.dll (from this package) in your C# project.

Above your BaseUnityPlugin class definition:

[BepInDependency(OverlayDearImGuiBepInEx5.PluginGUID)]

In OnEnable:

OverlayDearImGui.Overlay.Render += MyUI;

Example Render Function:

private static float _lastRefreshTime = -Mathf.Infinity;
private static GameObject[] _cachedInstances = Array.Empty<GameObject>();

private static void MyUI()
{
    if (ImGui.BeginMainMenuBar())
    {
        if (ImGui.BeginMenu("Debug", true))
        {
            if (ImGui.MenuItem("Open Debug Window", null, _isMyUIOpen))
            {
                _isMyUIOpen ^= true;
            }

            ImGui.EndMenu();
        }

        ImGui.EndMainMenuBar();
    }

    if (!_isMyUIOpen)
    {
        return;
    }

    if (Time.realtimeSinceStartup - _lastRefreshTime >= 2f)
    {
        _cachedInstances = UnityEngine.Object.FindObjectsOfType<GameObject>();
        _lastRefreshTime = Time.realtimeSinceStartup;
    }

    if (ImGui.Begin("GameObject Debug Viewer", ImGuiWindowFlags.AlwaysAutoResize))
    {
        ImGui.Text($"Found {_cachedInstances.Length} GameObject instances:");

        for (int i = 0; i < _cachedInstances.Length; i++)
        {
            var stuff = _cachedInstances[i];
            if (stuff == null)
            {
                continue;
            }

            var name = stuff.gameObject.name;
            var pos = stuff.transform.position;
            var active = stuff.gameObject.activeInHierarchy;

            ImGui.Separator();
            ImGui.Text($"[{i}] Name: {name}");
            ImGui.Text($"    Active: {active}");
            ImGui.Text($"    Position: {pos}");
        }

        ImGui.End();
    }
}

Thunderstore development is made possible with ads. Please consider making an exception to your adblock.
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.