Giter VIP home page Giter VIP logo

imgui-godot's Introduction

Dear ImGui plugin for Godot 4 (C#)

screenshot

Dear ImGui is a popular library for rapidly building tools for debugging and development. This plugin, with the aid of ImGui.NET, allows you to use ImGui in Godot with C#.

After installing the plugin, usage is as simple as this:

public partial class MyNode : Node
{
    public override void _Process(double delta)
    {
        ImGui.Begin("ImGui on Godot 4");
        ImGui.Text("hello world");
        ImGui.End();
    }
}

Download

Getting Started

Your project

  1. Create a project and, if you haven't already added some C# code, use Project > Tools > C# > Create C# solution.

  2. Install the plugin by copying over the addons folder. Or use GodotEnv.

  3. In Visual Studio or another IDE, open the solution and allow unsafe code, and install ImGui.NET with NuGet. Save and return to Godot.

    (If you prefer to manually edit the .csproj instead, refer to the demo csproj for the necessary modifications.)

  4. Back in the Godot editor, click Build.

  5. Enable the plugin in Project > Project Settings > Plugins.

  6. Write code!

Usage

In any Node's _Process method, use ImGuiNET to create your GUI. Just don't set the ProcessPriority in any of your Nodes to either int.MinValue or int.MaxValue.

Signals

You can also connect to the ImGuiLayout signal, and use ImGui in the method which handles that signal. This is strongly recommended if you're using process thread groups in Godot 4.1 or later.

ImGuiLayer.Connect(OnImGuiLayout);

Configuration

If you want to customize fonts or other settings, create an ImGuiConfig resource, then open the scene res://addons/imgui-godot/ImGuiLayer.tscn and set its Config property.

Widgets

These methods should only be called within _Process or an ImGuiLayout callback.

Image and ImageButton are simple wrappers for your convenience.

SubViewport displays an interactive viewport which receives input events. Be sure to change your SubViewport's Update Mode to Always.

ImGuiGD

This is the rest of the public API. You typically won't need to call any of these methods directly.

That's about it. Everything else is provided by ImGui itself, via ImGui.NET.

Mobile export

ImGui.NET does not support iOS or Android, so all ImGui related code should be conditionally disabled if you want to export for these platforms. For example:

#if !GODOT_MOBILE
ImGui.Begin("my window");
// ...
ImGui.End();
#endif

Package managers

GodotEnv is a dotnet tool that can manage Godot addons with just a little configuration. Use something like:

{
  "addons": {
    "imgui-godot": {
      "url": "https://github.com/pkdawson/imgui-godot",
      "checkout": "4.x",
      "subfolder": "addons/imgui-godot"
    }
  }
}

Credits

Code written by Patrick Dawson and contributors, released under the MIT license

Godot Logo (C) Andrea Calabró, distributed under the terms of the Creative Commons Attribution 4.0 International License (CC-BY-4.0 International) https://creativecommons.org/licenses/by/4.0/

Hack font distributed under the MIT license

M PLUS 2 font licensed under the SIL Open Font License, Version 1.1.

This plugin's functionality relies heavily on ImGui.NET by Eric Mellino

imgui-godot's People

Contributors

arran-nz avatar aschuhardt avatar pkdawson avatar valkyrienyanko avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.