mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 08:20:32 +00:00
Added ImGui.ShowDemo console variable to show/hide ImGui demo.
This commit is contained in:
parent
00ad746267
commit
8c46591488
@ -6,34 +6,46 @@
|
|||||||
#include "ImGuiModuleManager.h"
|
#include "ImGuiModuleManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace CVars
|
||||||
|
{
|
||||||
|
TAutoConsoleVariable<int> ShowDemo(TEXT("ImGui.ShowDemo"), 0,
|
||||||
|
TEXT("Show ImGui demo.\n")
|
||||||
|
TEXT("0: disabled (default)\n")
|
||||||
|
TEXT("1: enabled."),
|
||||||
|
ECVF_Default);
|
||||||
|
}
|
||||||
|
|
||||||
// Demo copied from ImGui examples. See https://github.com/ocornut/imgui.
|
// Demo copied from ImGui examples. See https://github.com/ocornut/imgui.
|
||||||
void FImGuiDemo::DrawControls()
|
void FImGuiDemo::DrawControls()
|
||||||
{
|
{
|
||||||
// 1. Show a simple window
|
if (CVars::ShowDemo.GetValueOnGameThread() > 0)
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
// 1. Show a simple window
|
||||||
ImGui::Text("Hello, world!");
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
{
|
||||||
ImGui::ColorEdit3("clear color", (float*)&ClearColor);
|
static float f = 0.0f;
|
||||||
if (ImGui::Button("Test Window")) bDemoShowTestWindow = !bDemoShowTestWindow;
|
ImGui::Text("Hello, world!");
|
||||||
if (ImGui::Button("Another Window")) bDemoShowAnotherTestWindow = !bDemoShowAnotherTestWindow;
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
ImGui::ColorEdit3("clear color", (float*)&ClearColor);
|
||||||
}
|
if (ImGui::Button("Test Window")) bDemoShowTestWindow = !bDemoShowTestWindow;
|
||||||
|
if (ImGui::Button("Another Window")) bDemoShowAnotherTestWindow = !bDemoShowAnotherTestWindow;
|
||||||
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
|
}
|
||||||
|
|
||||||
// 2. Show another simple window, this time using an explicit Begin/End pair
|
// 2. Show another simple window, this time using an explicit Begin/End pair
|
||||||
if (bDemoShowAnotherTestWindow)
|
if (bDemoShowAnotherTestWindow)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(200, 100), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(200, 100), ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::Begin("Another Window", &bDemoShowAnotherTestWindow);
|
ImGui::Begin("Another Window", &bDemoShowAnotherTestWindow);
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
||||||
if (bDemoShowTestWindow)
|
if (bDemoShowTestWindow)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::ShowTestWindow(&bDemoShowTestWindow);
|
ImGui::ShowTestWindow(&bDemoShowTestWindow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user