mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 08:20:32 +00:00
Added to ImGui Context Manager an event raised when a new context proxy is created.
This commit is contained in:
parent
b1d000f696
commit
e05cea2789
@ -122,6 +122,7 @@ FImGuiContextManager::FContextData& FImGuiContextManager::GetEditorContextData()
|
||||
if (UNLIKELY(!Data))
|
||||
{
|
||||
Data = &Contexts.Emplace(Utilities::EDITOR_CONTEXT_INDEX, FContextData{ GetEditorContextName(), Utilities::EDITOR_CONTEXT_INDEX, DrawMultiContextEvent, FontAtlas, -1 });
|
||||
ContextProxyCreatedEvent.Broadcast(Utilities::EDITOR_CONTEXT_INDEX, Data->ContextProxy);
|
||||
}
|
||||
|
||||
return *Data;
|
||||
@ -136,6 +137,7 @@ FImGuiContextManager::FContextData& FImGuiContextManager::GetStandaloneWorldCont
|
||||
if (UNLIKELY(!Data))
|
||||
{
|
||||
Data = &Contexts.Emplace(Utilities::STANDALONE_GAME_CONTEXT_INDEX, FContextData{ GetWorldContextName(), Utilities::STANDALONE_GAME_CONTEXT_INDEX, DrawMultiContextEvent, FontAtlas });
|
||||
ContextProxyCreatedEvent.Broadcast(Utilities::STANDALONE_GAME_CONTEXT_INDEX, Data->ContextProxy);
|
||||
}
|
||||
|
||||
return *Data;
|
||||
@ -176,6 +178,7 @@ FImGuiContextManager::FContextData& FImGuiContextManager::GetWorldContextData(co
|
||||
if (UNLIKELY(!Data))
|
||||
{
|
||||
Data = &Contexts.Emplace(Index, FContextData{ GetWorldContextName(World), Index, DrawMultiContextEvent, FontAtlas, WorldContext->PIEInstance });
|
||||
ContextProxyCreatedEvent.Broadcast(Index, Data->ContextProxy);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -186,6 +189,7 @@ FImGuiContextManager::FContextData& FImGuiContextManager::GetWorldContextData(co
|
||||
if (UNLIKELY(!Data))
|
||||
{
|
||||
Data = &Contexts.Emplace(Index, FContextData{ GetWorldContextName(World), Index, DrawMultiContextEvent, FontAtlas });
|
||||
ContextProxyCreatedEvent.Broadcast(Index, Data->ContextProxy);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -5,6 +5,14 @@
|
||||
#include "ImGuiContextProxy.h"
|
||||
|
||||
|
||||
// TODO: It might be useful to broadcast FContextProxyCreatedDelegate to users, to support similar cases to our ImGui
|
||||
// demo, but we would need to remove from that interface internal classes.
|
||||
|
||||
// Delegate called when new context proxy is created.
|
||||
// @param ContextIndex - Index for that world
|
||||
// @param ContextProxy - Created context proxy
|
||||
DECLARE_MULTICAST_DELEGATE_TwoParams(FContextProxyCreatedDelegate, int32, FImGuiContextProxy&);
|
||||
|
||||
// Manages ImGui context proxies.
|
||||
class FImGuiContextManager
|
||||
{
|
||||
@ -51,6 +59,9 @@ public:
|
||||
// draw the same content to multiple contexts.
|
||||
FSimpleMulticastDelegate& OnDrawMultiContext() { return DrawMultiContextEvent; }
|
||||
|
||||
// Delegate called when new context proxy is created.
|
||||
FContextProxyCreatedDelegate& OnContextProxyCreated() { return ContextProxyCreatedEvent; }
|
||||
|
||||
void Tick(float DeltaSeconds);
|
||||
|
||||
private:
|
||||
@ -107,5 +118,7 @@ private:
|
||||
|
||||
FSimpleMulticastDelegate DrawMultiContextEvent;
|
||||
|
||||
FContextProxyCreatedDelegate ContextProxyCreatedEvent;
|
||||
|
||||
ImFontAtlas FontAtlas;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user