mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-19 00:40:32 +00:00
c5f3759664
- Moved property variables to ImGui Module Properties. - Moved console command to ImGui Module Commands (one for now but more will be added). - ImGui Module Commands is created by ImGui Module Manager, what means that commands are registered after module is loaded and unregistered when it is unloaded. - Updated settings to allow more convenient use: Added global pointer to default object and event raised when it is loaded.
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
#include "ImGuiPrivatePCH.h"
|
|
|
|
#include "ImGuiInputHandlerFactory.h"
|
|
|
|
#include "ImGuiInputHandler.h"
|
|
#include "ImGuiSettings.h"
|
|
|
|
|
|
UImGuiInputHandler* FImGuiInputHandlerFactory::NewHandler(FImGuiModuleManager* ModuleManager, UGameViewportClient* GameViewport, int32 ContextIndex)
|
|
{
|
|
UClass* HandlerClass = nullptr;
|
|
if (GImGuiSettings)
|
|
{
|
|
const auto& HandlerClassReference = GImGuiSettings->GetImGuiInputHandlerClass();
|
|
if (HandlerClassReference.IsValid())
|
|
{
|
|
HandlerClass = HandlerClassReference.TryLoadClass<UImGuiInputHandler>();
|
|
|
|
if (!HandlerClass)
|
|
{
|
|
UE_LOG(LogImGuiInputHandler, Error, TEXT("Couldn't load ImGui Input Handler class '%s'."), *HandlerClassReference.ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!HandlerClass)
|
|
{
|
|
HandlerClass = UImGuiInputHandler::StaticClass();
|
|
}
|
|
|
|
UImGuiInputHandler* Handler = NewObject<UImGuiInputHandler>(GameViewport, HandlerClass);
|
|
if (Handler)
|
|
{
|
|
Handler->Initialize(ModuleManager, GameViewport, ContextIndex);
|
|
Handler->AddToRoot();
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogImGuiInputHandler, Error, TEXT("Failed attempt to create Input Handler: HandlerClass = %s."), *GetNameSafe(HandlerClass));
|
|
}
|
|
|
|
return Handler;
|
|
}
|
|
|
|
void FImGuiInputHandlerFactory::ReleaseHandler(UImGuiInputHandler* Handler)
|
|
{
|
|
if (Handler)
|
|
{
|
|
Handler->RemoveFromRoot();
|
|
}
|
|
}
|