Skip to content

Commit

Permalink
Merge pull request #16 from sammyfreg/dev
Browse files Browse the repository at this point in the history
Release 1.8
  • Loading branch information
sammyfreg authored Mar 6, 2022
2 parents 40956b0 + c515bfb commit d989b8a
Show file tree
Hide file tree
Showing 44 changed files with 151,978 additions and 382 deletions.
4 changes: 2 additions & 2 deletions NetImgui.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 7,
"VersionName": "1.7",
"Version": 8,
"VersionName": "1.8",
"FriendlyName": "Unreal NetImgui",
"Description": "Plugin exposing Dear ImGui library for drawing 2D menus. These menus are displayed and controlled from an external application but processed from this engine code.",
"Category": "2D",
Expand Down
Binary file modified NetImguiServer/netImguiServer.exe
Binary file not shown.
128 changes: 98 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,60 @@
<p align="center" style="font-size:30px"><b>Unreal NetImgui</b></p>
<br>
<p align="center">
<p align="center" style="vertical-align:middle">
<img src="https://avatars3.githubusercontent.com/u/6615685?s=200&v=4" width=128 height=128>
+
<img src="https://raw.githubusercontent.com/wiki/sammyfreg/netImgui/Web/img/DearImGui.png" width=128 height=128>
<img src="https://raw.githubusercontent.com/wiki/sammyfreg/netImgui/Web/img/netImguiLogo.png" width=128 height=128>
</p>

# Summary
### [Unreal Engine 4's](https://github.com/EpicGames) support of [NetImgui 1.7.5](https://github.com/sammyfreg/netImgui "NetImgui")
### Support of [NetImgui](https://github.com/sammyfreg/netImgui "NetImgui") in [Unreal Engine 4](https://github.com/EpicGames)

**NetImgui** is a library to remotely display and control **Dear ImGui** menus with a connected NetImgui server application.
**UnrealNetImgui** is a plugin adding remote debug GUI interface to **Unreal Engine** using the [**Dear ImGui**](https://github.com/ocornut/imgui "Dear ImGui") paired with [**NetImgui**](https://github.com/sammyfreg/netImgui). Allows **UE4** users to remotely display and control some custom GUI on the dedicated **NetImgui Server** application. This proves convenient with games running on limited inputs/display hardware, such as gaming consoles and smartphones. Also reduces the game screen clutter of debug informations contents.

This plugin allows **UE4** users to remotely connect to their game and display [**Dear ImGui**](https://github.com/ocornut/imgui "Dear ImGui")'s generated menus in a separate window. The game can be running on a different computer or even a different platform such as console, cellpone, etc...
![NetImgui](https://raw.githubusercontent.com/wiki/sammyfreg/netImgui/Web/img/UnrealNetImgui.gif)

![NetImgui](https://raw.githubusercontent.com/wiki/sammyfreg/netImgui/Web/img/UnrealCommands.gif)
> **Note 1:** Allows a simple use of **Dear ImGui** in **Unreal Engine 4**. To support more complex scenario with GUI content displayed locally on the game screen, please take a look at the excellent [**UnrealImGui**](https://github.com/segross/UnrealImGui/tree/net_imgui) plugin. It also has NetImgui support integrated in the **net_imgui branch**.
> **Note 2:** Useful library when **Dear ImGui** is not already supported in your UE4 engine codebase. Otherwise, ignore this plugin and add [**NetImgui's**](https://github.com/sammyfreg/netImgui "NetImgui") client code alongside your **Dear ImGui's** code. It requires minimal integration time and you can refer to this plugin for implementation details.
# Fonts and Icons
The plugin comes packaged with various Latin fonts, a Japanese Mincho font, [Kenney's Gaming Icons](https://kenney.nl/assets/game-icons "gaming icons"), [Font Awesome](https://fontawesome.com "Font Awesome") (the free subset) and [Google Material Designs icons](https://github.com/google/material-design-icons "Google Material Designs icons"), for a nice selection of useful icons. The screenshot above shows a small subset of available icons. Mixing latin text, kanjis and icons is kept straightforward using utf8 strings.

# Connecting to the NetImgui Server
There are mutliple ways of connecting your game to the **NetImguiServer**.

### Default
- Launch your Editor/Game on your local PC, a connection should be automatically be established when NetImguiServer and game are on the same PC.
- When launching on remote hardware, add connection information in the NetImgui Server's clients list. Then, the connection will also automatically be established.
- **Note :** The default behaviour is to start waiting on a connection from the NetImguiServer on the default port of the executable type 8889(Game) / 8890(Editor) / 8891(Dedicated Server). If you do not wish this plugin to automatically open a port, you can disable it in `NetImgui.Build.cs` and rely on the NetImgui commands below.

![NetImgui](https://raw.githubusercontent.com/wiki/sammyfreg/netImgui/Web/img/NetImguiServer_AddClient.gif)

### Optional
When launching your game or using the Unreal Console, you can also manually control the connection to the NetImguiServer using these commands:

> **Note 1:** Allows a very simple use of **NetImgui** in **Unreal Engine 4**. To support more complex usage, with **Dear ImGui** content displayed locally on the game screen, please take a look at the excellent [**UnrealImGui**](https://github.com/segross/UnrealImGui/tree/net_imgui) plugin. It also has NetImgui support integrated.
Command Name | Parameter | Description
--- | --- | ---
**NetImguiConnect** | Hostname/IP:[Port] | Try reaching the NetImgui Server Application directly.
**NetImguiListen** | [Port] | Start waiting for a connection from the NetImgui Server application (if not already connected).
**NetImguiDisconnect** | None | Disconnect from the NetImgui Server and stop waiting for a connection.

> **Note 2:** This is a useful plugin when **Dear ImGui** is not already supported in your UE4 engine codebase. Otherwise, it is possible to ignore this plugin and directly add [**NetImgui's**](https://github.com/sammyfreg/netImgui "NetImgui") client code alongside your **Dear ImGui's** code.
*Note :* The Port parameter is optional, it will use default values unless specified.

*Example :* `UE4Editor.exe -NetImguiListen` Launch Unreal Editor and wait for a connection on default port.

*Example :* `UE4Editor.exe -NetImguiListen 8000` Launch Unreal Editor and wait for a connection on port 8000.

*Example :* `UE4Editor.exe -NetImguiConnect MyPCName` Launch Unreal Editor and try connecting to NetImguiServer running on Windows PC with network name 'MyPCName' on default port.

*Example :* (In Unreal Console) `NetImguiConnect 192.168.1.10:7000` Launch Unreal Editor and try connecting to NetImguiServer running on PC with IP 192.168.1.10 and Port 7000.

# Unreal Commands
Integrated in the plugin, is the ***Imgui Unreal Commands*** functionalities. Allows user to quickly browse and execute the various Unreal Commands that are already available in the Console, but with a nicer interface.
This plugins comes with ***Imgui Unreal Commands***, adding Unreal Commands browsing and execution functionalities.

![NetImgui](https://raw.githubusercontent.com/wiki/sammyfreg/netImgui/Web/img/UnrealCommandsFull.gif)
![NetImgui](https://raw.githubusercontent.com/wiki/sammyfreg/netImgui/Web/img/UnrealCommands.gif)
**[[Demonstration Video]](https://raw.githubusercontent.com/wiki/sammyfreg/netImgui/Web/img/UnrealCommands.mp4 "[Demonstration Video]")**

- **Note :**
- The *Imgui Unreal Commands* support is early release.
- **I am interested in hearing back from people, to know what 'Preset' should comes by default**
Expand All @@ -36,18 +67,20 @@ Integrated in the plugin, is the ***Imgui Unreal Commands*** functionalities. Al
1. Regenerate your project solution to have the new plugin included *(right-click [ProjectName].uproject-> Generate Visual Studio Project Files)*
1. In your game project `(ProjectName).Build.cs` file, add the `NetImgui` dependency to `PublicDependencyModuleNames` entries.
1. In editor, enable the plugin `2D\NetImgui`.
1. Start the (`UnrealNetImgui\NetImguiServer\NetImguiServer.exe`) application.
1. Start the `UnrealNetImgui\NetImguiServer\NetImguiServer.exe` application.
- **Dear ImGui's** menu content created in your code, will be displayed and controlled in it (after a connection is established).
- The client list comes pre-configured with 2 clients configuration (game and editor running on the same PC). For remote PCs, game consoles or others, create a new client configuration with proper address settings.
1. Any code running on the Game Thread, can now make standard **Dear ImGui** drawing commands to generate your menus.
- The define `NETIMGUI_ENABLED` allows to selectively disable code if planning to disable **NetImgui** on certain game configurations (shipping, ...)
- By default, the plugin is compiled with **FrameSkip** support. This saves CPU but require a test before drawing. This means that the **Dear ImGui** functions should only be used when `FNetImguiModule::IsDrawing()` is true *(assert otherwise)*. This can be disabled with `bFrameSkip_Enabled` in `NetImgui.Build.cs`.
1. If wanting to use in editor, make sure to unselect the option `Edit->Editor Preferences->General->Performances->Use Less CPU when in Background`, otherwise framerate will be low when focus is on the NetImguiServer window instead of the Unreal Editor.
- The client list comes pre-configured with 3 clients configuration (game, editor, server) that will be automatically connected to when detected. For remote PCs, game consoles or others, create a new client configuration with proper address settings.
1. You can now invoke **Dear ImGui** drawing functions to generate your GUI every frame.
- Any code running on the Game Thread can now invoke make drawing calls (as long as `NetImguiHelper::IsDrawing()` is true)
- You can also add a callback to `FNetImguiModule::OnDrawImgui` to be invoked by **UnrealNetImgui** when some drawing is expected.
- The define `NETIMGUI_ENABLED` allows to selectively disable code if planning to remove **NetImgui** on certain game configurations (shipping, ...)
1. The Unreal build file `NetImgui.Build.cs` contains many option to toggle features/fonts.
1. When using this plugin in the Editor, unselect the option `Edit->Editor Preferences->General->Performances->Use Less CPU when in Background`, otherwise framerate will be low when focus is on the NetImguiServer window instead of the Unreal Editor.
# Example

Code example of **Dear ImGui** to display a very basic menu from the `Tick()` method of an actor.
- A slightly more complex sample can be found in `UnrealNetImgui\Source\Sample`
- The sample code is the actor `Net Imgui Demo Actor` that can be dropped in any of your scenes.
- A more detailed sample can be found in `UnrealNetImgui\Source\Sample\NetImguiDemoActor.*`.
- The sample actor `NetImguiDemoActor` can be dropped in any of your scenes.
- Information on [**Dear ImGui**](https://github.com/ocornut/imgui "Dear ImGui") menu generation, can be found reading the code of `ImGui::ShowDemoWindow()` in `UnrealNetImgui\Source\Private\ThirdParty\DearImgui\imgui_demo.cpp` and their webpage.

```cpp
Expand All @@ -64,39 +97,74 @@ void AMyImGuiActor::Tick(float DeltaTime)
// Avoid drawing ImGui menus when not expecting a new frame, reducing CPU cost.
// Mandatary when 'bSupportFrameSkip' is emabled in 'NetImgui.Build.cs', otherwise
// 'Dear ImGui' will assert on a missing 'ImGui::NewFrame()'
if( FNetImguiModule::IsDrawing() )
//---------------------------------------------------------------------------------------------
if( NetImguiHelper::IsDrawing() )
{
//-----------------------------------------------------------------------------------------
// A single 'AMyImGuiActor' will display the following content
// (could use a FCoreDelegates::OnBeginFrame delegate instead of checking frame number)
//-----------------------------------------------------------------------------------------
// First 'ANetImguiDemoActor' actor will display the following content
// (could use 'FNetImguiModule::OnDrawImgui' callback delegate instead)
//-----------------------------------------------------------------------------------------
static uint64 sLastFrame = 0;
if( sLastFrame != GFrameCounter )
{
sLastFrame = GFrameCounter;
ImGui::Begin("NetImgui Demo");
ImGui::TextWrapped("Simple display of a text label");
ImGui::TextUnformatted("I " ICON_KI_HEART " icons in my text."); // Display 'I (HeartIcon) icons in my text
ImGui::End();
ImGui::ShowDemoWindow();
ImGui::ShowDemoWindow(); // Show Dear ImGui demo window
}

//-----------------------------------------------------------------------------------------
// Every 'ANetImguiDemoActor' display the following content
//-----------------------------------------------------------------------------------------
FString windowName = FString::Format(TEXT("DemoActor: {0}"), {GetName()});
ImGui::SetNextWindowSize(ImVec2(400.f, 200.f), ImGuiCond_Once);
if (ImGui::Begin(TCHAR_TO_UTF8(*windowName)))
{
ImGui::Text("Name: ");
ImGui::SameLine(64.f);
ImGui::TextUnformatted(TCHAR_TO_UTF8(*GetName()));

FVector pos = GetTransform().GetLocation();
ImGui::Text( "Pos: ");
ImGui::SameLine(64.f);
ImGui::Text("(%.02f, %.02f, %.02f)", pos.X, pos.Y, pos.Z);
}
ImGui::End();
}
#endif
}
```
# Release notes 1.4
- Upgraded to [**NetImgui 1.6**](https://github.com/sammyfreg/netImgui "NetImgui") *(more details in link)*
- NetImgui Server keyboard Input fixes
- Added ***Imgui Unreal Commands*** support (browse and execute Unreal Commands)
# Release notes 1.8
- Added Japanese Font
- Added Kenney's gaming icons
- Added Font Awesome's icons
- Added Font Material Design icons
- Added FreeType font rendering support (for sharper text)
- Added the delegate `FNetImguiModule::OnDrawImgui` to listen to for drawing
- Cache module lookup(every frame) when calling `FNetImguiModule::Get()` instead of more expensive search
- Upgraded to [**NetImgui 1.7.5**](https://github.com/sammyfreg/netImgui/releases/tag/v1.7.5) *(more details in link)*
# Release notes (older)
- Upgraded to [**NetImgui 1.6**](https://github.com/sammyfreg/netImgui/releases/tag/v1.6.0) *(more details in link)*
- NetImgui Server keyboard Input fixes
- Added ***Imgui Unreal Commands*** support (browse and execute Unreal Commands)
- Upgraded to **Dear Imgui 1.83** *(docking branch)*
- Upgraded to [**NetImgui 1.5**](https://github.com/sammyfreg/netImgui "NetImgui") *(more details in link)*
- Upgraded to [**NetImgui 1.5**](https://github.com/sammyfreg/netImgui/releases/tag/v1.5.0) *(more details in link)*
- Tested on **Unreal 4.26** *(other versions should be supported without issues)*
- **NetImgui Server** now requires less CPU/GPU
# Credits
Sincere thanks to [Omar Cornut](https://github.com/ocornut/imgui/commits?author=ocornut) for the incredible work on [**Dear ImGui**](https://github.com/ocornut/imgui).
Code inspired by existing [**UnrealImGui**](https://github.com/segross/UnrealImGui/tree/net_imgui) plugin for Unreal 4.
Code inspired by existing [**UnrealImGui**](https://github.com/segross/UnrealImGui/tree/net_imgui) plugin for Unreal 4.
**Icons**
Various icons have been integrated to **UnrealNetImgui** existing fonts and accessible as normal unicode entries. The following credits made it possible:
- [IconFontCppHeaders](https://github.com/juliettef/IconFontCppHeaders "IconFontCppHeaders") by Doug Binks, giving easy access to icons symbols, using simple C++ defines.
- [Kenney's Gaming Icons](https://kenney.nl/assets/game-icons "gaming icons") for his set of useful game related symbols.
- [Font Awesome](https://fontawesome.com "Font Awesome") (the free subset) for the nice selection of every day use icons.
Loading

0 comments on commit d989b8a

Please sign in to comment.