{"id":18681692,"url":"https://github.com/mrrobinofficial/guide-unitydearimgui","last_synced_at":"2025-04-12T04:09:30.947Z","repository":{"id":63775234,"uuid":"570644176","full_name":"MrRobinOfficial/Guide-UnityDearImGui","owner":"MrRobinOfficial","description":"This repository is designed to help developers learn how to get started with dear-imgui. This project includes tutorials and examples for using dear-imgui with the Unity.","archived":false,"fork":false,"pushed_at":"2023-07-12T20:41:28.000Z","size":531,"stargazers_count":19,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T04:09:27.312Z","etag":null,"topics":["dearimgui","developer-tools","unity","unity3d"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrRobinOfficial.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-25T17:46:01.000Z","updated_at":"2024-12-28T18:15:22.000Z","dependencies_parsed_at":"2025-04-12T04:09:29.540Z","dependency_job_id":null,"html_url":"https://github.com/MrRobinOfficial/Guide-UnityDearImGui","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRobinOfficial%2FGuide-UnityDearImGui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRobinOfficial%2FGuide-UnityDearImGui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRobinOfficial%2FGuide-UnityDearImGui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRobinOfficial%2FGuide-UnityDearImGui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrRobinOfficial","download_url":"https://codeload.github.com/MrRobinOfficial/Guide-UnityDearImGui/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514222,"owners_count":21116903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dearimgui","developer-tools","unity","unity3d"],"created_at":"2024-11-07T10:08:46.428Z","updated_at":"2025-04-12T04:09:30.925Z","avatar_url":"https://github.com/MrRobinOfficial.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Banner](static/img/Banner.png)\n\n\u003cdiv align=\"center\"\u003e\n  \n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/mrrobinofficial/guide-unitysteamnetcodegameobjects/blob/HEAD/LICENSE.txt)\n![guide-status](https://img.shields.io/badge/guide_status-completed-green)\n\n\u003c/div\u003e\n\n#\n\n\u003ccenter\u003e\n    \u003cp\u003e\n        \u003ci\u003e\n            This repo is a comprehensive repository designed to help users quickly and effectively get started with integrating Dear ImGui, a bloat-free graphical user interface library, into their Unity projects. Dear ImGui provides a lightweight, customizable, and efficient GUI solution that allows you to create user interfaces for your applications and games with ease.\n        \u003c/i\u003e\n    \u003c/p\u003e\n\u003c/center\u003e\n\n## ⚙️ Before you begin\n\nrealgamessoftware - [Original Repo](https://github.com/realgamessoftware/dear-imgui-unity)\n\nmattmanj17 - [Forked Repo](https://github.com/mattmanj17/dear-imgui-unity#matthewd)\n\nForked repo fixes an issue from Unity version 2020.1.0b4: https://github.com/realgamessoftware/dear-imgui-unity/issues/28\n\n## ⚒️ How to Install\n\n* Install via Package Manager by clicking on [add package](https://docs.unity3d.com/Manual/upm-ui-giturl.html), then enter this git URL:\n\n```console\nhttps://github.com/mattmanj17/dear-imgui-unity.git#matthewd\n```\n\n## 📝 How To Use It\n\n* Add a DearImGui component to one of the objects in the scene.\n* Create 'Ini Settings Asset' and 'Font Atlas Config Asset' in the project folder.\n* Add custom fonts to the '[StreamingAssets](https://docs.unity3d.com/Manual/StreamingAssets.html)' folder and link it up to the 'Font Atlas Config Asset'.\n* Change the 'Font pixel' in the 'Font Atlas Config Asset', to scale up the font size.\n* When using the Universal Render Pipeline, add a Render Im Gui Feature render feature to the renderer asset. Assign it to the render feature field of the DearImGui component.\n* Subscribe to the ImGuiUn.Layout event and use ImGui functions.\n\n## 🧠 Scripts\n\nSimple Script\n\n```csharp\nusing UnityEngine;\nusing ImGuiNET;\n\npublic class DearImGuiDemo : MonoBehaviour\n{\n    void OnEnable()\n    {\n        ImGuiUn.Layout += OnLayout;\n    }\n\n    void OnDisable()\n    {\n        ImGuiUn.Layout -= OnLayout;\n    }\n\n    void OnLayout()\n    {\n        ImGui.ShowDemoWindow();\n    }\n}\n```\n\nAdvanced Script\n\n```csharp\nusing ImGuiNET;\nusing UnityEngine;\nusing UnityEngine.Events;\n\npublic class DearImGuiDemoWindow : MonoBehaviour\n{\n    private static UnityAction OnUpdateLighting;\n    private static UnityAction OnLoadGame;\n    private static UnityAction OnSaveGame;\n\n    private void OnEnable() =\u003e ImGuiUn.Layout += OnLayout;\n\n    private void OnDisable() =\u003e ImGuiUn.Layout -= OnLayout;\n\n    private static readonly Vector4 TEXT_COLOR = new(1f, 0.8f, 0f, 1.0f);\n\n    private float m_Timeline = 0.5f;\n    private System.TimeSpan m_Time = System.TimeSpan.FromHours(12.0f);\n    private string m_Username = string.Empty;\n    private string m_Password = string.Empty;\n    private Vector3 m_SunColor = new(1.0f, 0.9f, 0f);\n    private bool m_WindowEnabled = false;\n    private bool m_EnableDayAndNightCycle = true;\n    private int m_DragInt = 0;\n    private int m_AccountCount = 0;\n    private bool m_ShowImGuiDemoWindow;\n    private static uint s_tab_bar_flags = (uint)ImGuiTabBarFlags.Reorderable;\n    static bool[] s_opened = { true, true, true, true }; // Persistent user state\n\n    /**\n     * DearImGui\n     * Manual - https://pthom.github.io/imgui_manual_online/manual/imgui_manual.html\n     */\n\n    private void OnLayout()\n    {\n        // Begins ImGui window\n        if (!ImGui.Begin(\"Game Manager\",\n                         ref m_WindowEnabled,\n                         ImGuiWindowFlags.MenuBar))\n            return;\n\n        ImGui.Checkbox(\"Enable Day And Night Cycle\", ref m_EnableDayAndNightCycle);\n\n        // Make a float slider (label, value, min, max) \n        if (ImGui.SliderFloat(\"Time [%]\", ref m_Timeline, 0f, 1f) \u0026\u0026 m_EnableDayAndNightCycle)\n        {\n            m_Time = System.TimeSpan.FromSeconds(m_Timeline * 86400f);\n            OnUpdateLighting?.Invoke();\n        }\n\n        // Display text of current in-game time\n        ImGui.TextColored(TEXT_COLOR, $\"In-game Time: {m_Time:hh\\\\:mm}\");\n\n        // Create color editor for Vector3\n        ImGui.ColorEdit3(\"Sun Color\", ref m_SunColor);\n\n        // Creates a menu bar\n        if (ImGui.BeginMenuBar())\n        {\n            if (ImGui.BeginMenu(\"File\"))\n            {\n                if (ImGui.MenuItem(\"Open\", shortcut: \"Ctrl+O\"))\n                    Debug.Log(\"Opening a file...\");\n\n                if (ImGui.MenuItem(\"Save\", shortcut: \"Ctrl+S\"))\n                    Debug.Log(\"Saving a file...\");\n\n                if (ImGui.MenuItem(\"Close\", shortcut: \"Ctrl+W\"))\n                {\n                    m_WindowEnabled = false;\n                    Debug.Log(\"Closing this window...\");\n                }\n\n                ImGui.EndMenu();\n            }\n\n            ImGui.EndMenuBar();\n        }\n\n        if (ImGui.Button(\"Load Game\"))\n        {\n            OnLoadGame?.Invoke();\n            Debug.Log(\"Loading the game...\");\n        }\n\n        if (ImGui.Button(\"Save Game\"))\n        {\n            OnSaveGame?.Invoke();\n            Debug.Log(\"Saving the game...\");\n        }\n\n        if (ImGui.Button(\"Create Account\"))\n        {\n            Debug.Log(\"Creating account...\");\n            m_AccountCount++;\n        }\n\n        ImGui.SameLine(0, -1);\n        ImGui.Text($\"Account Count = {m_AccountCount}\");\n\n        // Create input field (label, value, maxLength [uint])\n        ImGui.InputText(\"Username\", ref m_Username, maxLength: 12u);\n        ImGui.InputText(\"Password\", ref m_Password, maxLength: 16u);\n\n        ImGui.Text($\"Mouse position: {ImGui.GetMousePos()}\");\n\n        // Display contents in a scrolling region\n        ImGui.TextColored(TEXT_COLOR, \"Important Stuff\");\n        ImGui.BeginChild(\"Scrolling\");\n\n        for (int n = 0; n \u003c 50; n++)\n            ImGui.Text($\"{n:0000}: Some text\");\n\n        ImGui.EndChild();\n\n        // Generate samples and plot them\n        float[] samples = new float[100];\n\n        for (int n = 0; n \u003c 100; n++)\n            samples[n] = Mathf.Sin((float)(n * 0.2f + ImGui.GetTime() * 1.5f));\n\n        ImGui.PlotLines(\"Samples\", ref samples[0], 100);\n\n        ImGui.DragInt(\"Draggable Int\", ref m_DragInt);\n\n        float framerate = ImGui.GetIO().Framerate;\n        ImGui.Text($\"Application average {1000.0f / framerate:0.##} ms/frame ({framerate:0.#} FPS)\");\n\n        if (m_ShowImGuiDemoWindow)\n        {\n            // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway.\n            // Here we just want to make the demo initial state a bit more friendly!\n            ImGui.SetNextWindowPos(new Vector2(650, 20), ImGuiCond.FirstUseEver);\n            ImGui.ShowDemoWindow(ref m_ShowImGuiDemoWindow);\n        }\n\n        if (ImGui.TreeNode(\"Tabs\"))\n        {\n            if (ImGui.TreeNode(\"Basic\"))\n            {\n                ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags.None;\n\n                if (ImGui.BeginTabBar(\"MyTabBar\", tab_bar_flags))\n                {\n                    if (ImGui.BeginTabItem(\"Avocado\"))\n                    {\n                        ImGui.Text(\"This is the Avocado tab!\\nblah blah blah blah blah\");\n                        ImGui.EndTabItem();\n                    }\n\n                    if (ImGui.BeginTabItem(\"Broccoli\"))\n                    {\n                        ImGui.Text(\"This is the Broccoli tab!\\nblah blah blah blah blah\");\n                        ImGui.EndTabItem();\n                    }\n\n                    if (ImGui.BeginTabItem(\"Cucumber\"))\n                    {\n                        ImGui.Text(\"This is the Cucumber tab!\\nblah blah blah blah blah\");\n                        ImGui.EndTabItem();\n                    }\n\n                    ImGui.EndTabBar();\n                }\n\n                ImGui.Separator();\n                ImGui.TreePop();\n            }\n\n            if (ImGui.TreeNode(\"Advanced \u0026 Close Button\"))\n            {\n                // Expose a couple of the available flags. In most cases you may just call BeginTabBar() with no flags (0).\n                ImGui.CheckboxFlags(\"ImGuiTabBarFlags_Reorderable\", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.Reorderable);\n                ImGui.CheckboxFlags(\"ImGuiTabBarFlags_AutoSelectNewTabs\", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.AutoSelectNewTabs);\n                ImGui.CheckboxFlags(\"ImGuiTabBarFlags_NoCloseWithMiddleMouseButton\", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.NoCloseWithMiddleMouseButton);\n                if ((s_tab_bar_flags \u0026 (uint)ImGuiTabBarFlags.FittingPolicyMask) == 0)\n                    s_tab_bar_flags |= (uint)ImGuiTabBarFlags.FittingPolicyDefault;\n                if (ImGui.CheckboxFlags(\"ImGuiTabBarFlags_FittingPolicyResizeDown\", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.FittingPolicyResizeDown))\n                    s_tab_bar_flags \u0026= ~((uint)ImGuiTabBarFlags.FittingPolicyMask ^ (uint)ImGuiTabBarFlags.FittingPolicyResizeDown);\n                if (ImGui.CheckboxFlags(\"ImGuiTabBarFlags_FittingPolicyScroll\", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.FittingPolicyScroll))\n                    s_tab_bar_flags \u0026= ~((uint)ImGuiTabBarFlags.FittingPolicyMask ^ (uint)ImGuiTabBarFlags.FittingPolicyScroll);\n\n                // Tab Bar\n                string[] names = { \"Artichoke\", \"Beetroot\", \"Celery\", \"Daikon\" };\n\n                for (int n = 0; n \u003c s_opened.Length; n++)\n                {\n                    if (n \u003e 0) { ImGui.SameLine(); }\n                    ImGui.Checkbox(names[n], ref s_opened[n]);\n                }\n\n                // Passing a bool* to BeginTabItem() is similar to passing one to Begin(): the underlying bool will be set to false when the tab is closed.\n                if (ImGui.BeginTabBar(\"MyTabBar\", (ImGuiTabBarFlags)s_tab_bar_flags))\n                {\n                    for (int n = 0; n \u003c s_opened.Length; n++)\n                    {\n                        if (s_opened[n] \u0026\u0026 ImGui.BeginTabItem(names[n], ref s_opened[n]))\n                        {\n                            ImGui.Text($\"This is the {names[n]} tab!\");\n                            if ((n \u0026 1) != 0)\n                                ImGui.Text(\"I am an odd tab.\");\n                            ImGui.EndTabItem();\n                        }\n                    }\n\n                    ImGui.EndTabBar();\n                }\n\n                ImGui.Separator();\n                ImGui.TreePop();\n            }\n\n            ImGui.TreePop();\n        }\n\n        // Ends ImGui window\n        ImGui.End();\n    }\n}\n```\n\n## 🔗 Helpful links\n\n* [Dear ImGui Manual In C++](https://pthom.github.io/imgui_manual_online/manual/imgui_manual.html)\n* [realgamessoftware - Original Repo](https://github.com/realgamessoftware/dear-imgui-unity/issues)\n* [mattmanj17 - Forked Repo](https://github.com/mattmanj17/dear-imgui-unity#matthewd)\n* [ImGui.NET - Repo](https://github.com/mellinoe/ImGui.NET)\n* [cimgui - Repo](https://github.com/cimgui/cimgui)\n* [imgui - 'Creator' Repo](https://github.com/ocornut/imgui)\n\n## 📌 See Also\nThis package uses Dear ImGui C bindings by [cimgui](https://github.com/cimgui/cimgui) and the C# wrapper by [ImGui.NET](https://github.com/mellinoe/ImGui.NET).\n\nThe development project for the package can be found at https://github.com/realgamessoftware/dear-imgui-unity-dev .\n\n## 🆘 Support\nIf you have any questions or issue, just write either to my [YouTube channel](https://www.youtube.com/@mrrobinofficial), [Email](mailto:mrrobin123mail@gmail.com) or [Twitter DM](https://twitter.com/MrRobinOfficial).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrrobinofficial%2Fguide-unitydearimgui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrrobinofficial%2Fguide-unitydearimgui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrrobinofficial%2Fguide-unitydearimgui/lists"}