mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 16:30:32 +00:00
d4ffe9443f
- Removed explicit PCH. - Fixed includes to compile for all supported engine versions, including non-unity builds. - Configured build.cs to treat ImGui as an engine module and added stricter compilation rules.
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
#include "ImGuiInputHandlerFactory.h"
|
|
#include "ImGuiInputHandler.h"
|
|
|
|
#include "ImGuiModuleDebug.h"
|
|
|
|
#include <Engine/GameViewportClient.h>
|
|
#include <InputCoreTypes.h>
|
|
|
|
|
|
UImGuiInputHandler* FImGuiInputHandlerFactory::NewHandler(const FStringClassReference& HandlerClassReference, FImGuiModuleManager* ModuleManager, UGameViewportClient* GameViewport, int32 ContextIndex)
|
|
{
|
|
UClass* HandlerClass = nullptr;
|
|
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();
|
|
}
|
|
}
|