xiaoxiao921-OverlayDearImGui_BepInEx5 icon

OverlayDearImGui BepInEx5

Overlay Window for Dear ImGui

Last updated 19 hours ago
Total downloads 15
Total rating 0 
Categories Libraries
Dependency string xiaoxiao921-OverlayDearImGui_BepInEx5-2.0.0
Dependants 0 other packages depend on this package

This mod requires the following mods to function

bbepis-BepInExPack-5.4.2120 icon
bbepis-BepInExPack

Unified BepInEx all-in-one modding pack - plugin framework, detour library

Preferred version: 5.4.2120
xiaoxiao921-OverlayDearImGui_Shared-2.0.0 icon
xiaoxiao921-OverlayDearImGui_Shared

Overlay Window for Dear ImGui

Preferred version: 2.0.0

README

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();
    }
}