From d82effdd5f5a4e9e62ce6bad38006b1277c8bf65 Mon Sep 17 00:00:00 2001 From: Arnaud Jamin Date: Wed, 11 Oct 2023 00:13:07 -0400 Subject: [PATCH 1/3] Update README.md --- README.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8721102..1083d95 100644 --- a/README.md +++ b/README.md @@ -192,10 +192,10 @@ The Cog repository has the following structure: - `Plugins/CogWindow` - ImGui window management (Base Window, Layout) - `Plugins/CogDebug` - Debug functionalities (Log, Debug Draw, Plot, Metric, ...) - `Plugins/CogImGui` - Integration of Imgui for Unreal, inspired by [UnrealImGui](https://github.com/segross/UnrealImGui) -- `Plugins/CogInterface` - Interfaces implemented by actors to inspect them +- `Plugins/CogCommon` - Common headers -The reason for having multiple plugins is to ease the integration for projects that do not use the `Ability System Component` or `Enhanced Input`. -For the next step of the setup, it is assumed all the plugins are used. +Cog has multiple plugins to ease the integration for projects that do not use the `Ability System Component` or `Enhanced Input`. +For the setup next steps, it is assumed all the plugins are used. 1. Setup up module dependencies: @@ -238,7 +238,70 @@ public class CogSample : ModuleRules } } ``` - +2. In the class of your choice (in the sample we use the GameState class) add a reference to the CogWindowManager. +#pragma once +```cpp +//ACogSampleGameState.h + +#include "CoreMinimal.h" +#include "CogCommon.h" +#include "GameFramework/GameStateBase.h" +#include "CogSampleGameState.generated.h" + +class UCogWindowManager; + +UCLASS() +class ACogSampleGameState : public AGameStateBase +{ + GENERATED_BODY() + + [...] + + // To make sure it doesn't get garbage collected. + UPROPERTY() + TObjectPtr CogWindowManagerRef = nullptr; + +#if ENABLE_COG + TObjectPtr CogWindowManager = nullptr; +#endif //ENABLE_COG +}; +``` +3. Instantiate the CogWindowManager and add some windows: + +```cpp +void ACogSampleGameState::BeginPlay() +{ + Super::BeginPlay(); + +#if ENABLE_COG + CogWindowManager = NewObject(this); + CogWindowManagerRef = CogWindowManager; + CogWindowManager->CreateWindow("Engine.Debug Settings"); + CogWindowManager->CreateWindow("Engine.ImGui"); + [...] +#endif //ENABLE_COG +} + +``` + +3. Define which key will toggle the input from the game to Imgui: + +```cpp +FCogImguiModule::Get().SetToggleInputKey(FCogImGuiKeyInfo(EKeys::Insert)); +``` + +4. Tick the CogWindowManager: + +```cpp +void ACogSampleGameState::Tick(float DeltaSeconds) +{ + Super::Tick(DeltaSeconds); + +#if ENABLE_COG + CogWindowManager->Tick(DeltaSeconds); +#endif //ENABLE_COG +} +``` From ad8e49f590ea944e1bc0ae312dae819ce2b49839 Mon Sep 17 00:00:00 2001 From: Arnaud Jamin Date: Wed, 11 Oct 2023 00:17:56 -0400 Subject: [PATCH 2/3] Update README.md --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1083d95..14b46e5 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ You must have Unreal 5.1 or greater and Visual Studio to launch the sample 7. Once in Unreal, press Play (Alt+P) 8. Press the `[Insert]` key or use the `Cog.ToggleInput` console command to open the Imgui Main Menu. -### Integrating Cog into your project +### Integrating Cog in your project The Cog repository has the following structure: - `CogSample` - A Sample that demonstrate various Cog functionalities. The project was saved in Unreal 5.1 @@ -194,12 +194,12 @@ The Cog repository has the following structure: - `Plugins/CogImGui` - Integration of Imgui for Unreal, inspired by [UnrealImGui](https://github.com/segross/UnrealImGui) - `Plugins/CogCommon` - Common headers -Cog has multiple plugins to ease the integration for projects that do not use the `Ability System Component` or `Enhanced Input`. -For the setup next steps, it is assumed all the plugins are used. +Cog has multiple plugins to ease the integration for projects that do not use the `Ability System Component` or `Enhanced Input`. For the next steps, it is assumed all the plugins are used. 1. Setup up module dependencies: ```c# +// CogSample.Build.cs using UnrealBuildTool; public class CogSample : ModuleRules @@ -239,12 +239,11 @@ public class CogSample : ModuleRules } ``` -2. In the class of your choice (in the sample we use the GameState class) add a reference to the CogWindowManager. - -#pragma once +2. In the class of your choice (in the sample we use the GameState class) add a reference to the CogWindowManager: ```cpp -//ACogSampleGameState.h +// ACogSampleGameState.h +#pragma once #include "CoreMinimal.h" #include "CogCommon.h" @@ -272,6 +271,7 @@ class ACogSampleGameState : public AGameStateBase 3. Instantiate the CogWindowManager and add some windows: ```cpp +// ACogSampleGameState.cpp void ACogSampleGameState::BeginPlay() { Super::BeginPlay(); @@ -279,6 +279,8 @@ void ACogSampleGameState::BeginPlay() #if ENABLE_COG CogWindowManager = NewObject(this); CogWindowManagerRef = CogWindowManager; + + // Add some windows CogWindowManager->CreateWindow("Engine.Debug Settings"); CogWindowManager->CreateWindow("Engine.ImGui"); [...] @@ -290,12 +292,14 @@ void ACogSampleGameState::BeginPlay() 3. Define which key will toggle the input from the game to Imgui: ```cpp +// ACogSampleGameState.cpp FCogImguiModule::Get().SetToggleInputKey(FCogImGuiKeyInfo(EKeys::Insert)); ``` 4. Tick the CogWindowManager: ```cpp +// ACogSampleGameState.cpp void ACogSampleGameState::Tick(float DeltaSeconds) { Super::Tick(DeltaSeconds); From 702f75fdee8924911790d308eed3f02dc214196d Mon Sep 17 00:00:00 2001 From: Arnaud Jamin Date: Wed, 11 Oct 2023 00:19:13 -0400 Subject: [PATCH 3/3] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 14b46e5..c9462a7 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,6 @@ public class CogSample : ModuleRules "GameplayTasks", "GameplayAbilities", "GameplayTags", - "HeadMountedDisplay", "InputCore", "NetCore", });