Skip to content

Commit

Permalink
Support for future web export
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdawson committed Jan 14, 2024
1 parent 22fd781 commit 7cb6890
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 19 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
[Dear ImGui](https://github.com/ocornut/imgui) is a popular library for rapidly building tools for debugging and development. This plugin, with the aid of [ImGui.NET](https://github.com/ImGuiNET/ImGui.NET), allows you to use ImGui in Godot with C#.

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

```csharp
public partial class MyNode : Node
{
Expand All @@ -30,7 +31,6 @@ 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`.
Expand All @@ -54,6 +54,7 @@ In any Node's `_Process` method, use `ImGuiNET` to create your GUI. Just don't s
### 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.

```csharp
ImGuiLayer.Connect(OnImGuiLayout);
```
Expand All @@ -78,17 +79,16 @@ 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:
ImGui.NET does not support iOS, Android, or web, so all ImGui related code should be conditionally disabled if you want to export for these platforms. For example:

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


## Package managers

[GodotEnv](https://github.com/chickensoft-games/GodotEnv/) is a dotnet tool that can manage Godot addons with just a little configuration. Use something like:
Expand All @@ -105,12 +105,11 @@ ImGui.End();
}
```


## 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/
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](https://github.com/source-foundry/Hack/blob/master/LICENSE.md)

Expand Down
2 changes: 1 addition & 1 deletion addons/imgui-godot/ImGuiGodot/ImGuiLayer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Godot;
#if !GODOT_MOBILE
#if GODOT_PC
using ImGuiNET;
using System;
using System.Collections.Generic;
Expand Down
2 changes: 1 addition & 1 deletion addons/imgui-godot/ImGuiGodot/Internal/CanvasRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !GODOT_MOBILE
#if GODOT_PC
using Godot;
using ImGuiNET;
using System;
Expand Down
2 changes: 1 addition & 1 deletion addons/imgui-godot/ImGuiGodot/Internal/DummyRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !GODOT_MOBILE
#if GODOT_PC
using Godot;
using ImGuiNET;

Expand Down
2 changes: 1 addition & 1 deletion addons/imgui-godot/ImGuiGodot/Internal/Fonts.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !GODOT_MOBILE
#if GODOT_PC
using Godot;
using ImGuiNET;
using System;
Expand Down
2 changes: 1 addition & 1 deletion addons/imgui-godot/ImGuiGodot/Internal/Input.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !GODOT_MOBILE
#if GODOT_PC
using Godot;
using ImGuiNET;
using System;
Expand Down
2 changes: 1 addition & 1 deletion addons/imgui-godot/ImGuiGodot/Internal/RdRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !GODOT_MOBILE
#if GODOT_PC
using Godot;
using ImGuiNET;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !GODOT_MOBILE
#if GODOT_PC
using Godot;
using ImGuiNET;
using System;
Expand Down
2 changes: 1 addition & 1 deletion addons/imgui-godot/ImGuiGodot/Internal/State.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !GODOT_MOBILE
#if GODOT_PC
using Godot;
using ImGuiNET;
using System;
Expand Down
2 changes: 1 addition & 1 deletion addons/imgui-godot/ImGuiGodot/Internal/Util.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !GODOT_MOBILE
#if GODOT_PC
using Godot;
using System;
using System.Reflection;
Expand Down
2 changes: 1 addition & 1 deletion addons/imgui-godot/ImGuiGodot/Internal/Viewports.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !GODOT_MOBILE
#if GODOT_PC
using Godot;
using ImGuiNET;
using System;
Expand Down
2 changes: 1 addition & 1 deletion addons/imgui-godot/ImGuiGodot/Widgets.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !GODOT_MOBILE
#if GODOT_PC
using Godot;
using ImGuiNET;
using System;
Expand Down
2 changes: 1 addition & 1 deletion src/MyNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override void _Ready()

public override void _Process(double delta)
{
#if !GODOT_MOBILE
#if GODOT_PC
ImGui.ShowDemoWindow();
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/MySecondNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace DemoProject;

public partial class MySecondNode : Node
{
#if !GODOT_MOBILE
#if GODOT_PC
private Texture2D _iconTexture = null!;
private AtlasTexture _atlasTexture = null!;
private SubViewport _vp = null!;
Expand Down

0 comments on commit 7cb6890

Please sign in to comment.