UDocumentation
UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InteractiveToolsContext.h
Go to the documentation of this file.
1
// Copyright Epic Games, Inc. All Rights Reserved.
2
3
#pragma once
4
5
#include "
Containers/UnrealString.h
"
6
#include "
CoreMinimal.h
"
7
#include "
Delegates/Delegate.h
"
8
#include "
InteractiveGizmoManager.h
"
9
#include "
InteractiveTool.h
"
10
#include "
InteractiveToolManager.h
"
11
#include "
Templates/Function.h
"
12
#include "
UObject/Object.h
"
13
#include "
UObject/ObjectMacros.h
"
14
#include "
UObject/ObjectPtr.h
"
15
#include "
UObject/SoftObjectPtr.h
"
16
#include "
UObject/UObjectGlobals.h
"
17
18
#include "InteractiveToolsContext.generated.h"
19
20
class
FText
;
21
class
IToolsContextQueriesAPI
;
22
class
IToolsContextTransactionsAPI
;
23
class
UContextObjectStore
;
24
class
UInputRouter
;
25
class
UInteractiveGizmoManager
;
26
class
UToolTargetManager
;
27
28
37
UCLASS
(
Transient
, MinimalAPI)
38
class
UInteractiveToolsContext
:
public
UObject
39
{
40
GENERATED_BODY
()
41
42
public
:
43
INTERACTIVETOOLSFRAMEWORK_API
UInteractiveToolsContext
();
44
45
// FContextInitInfo is used by Initialize() to pass information to the various creator functions below.
46
// See ::UInteractiveToolsContext() and ::Initialize() for how these fields are used/initialized.
47
// In particular, InputRouter will not be set until after the UInputRouter has been created
48
struct
FContextInitInfo
49
{
50
UInteractiveToolsContext
* ToolsContext =
nullptr
;
51
IToolsContextQueriesAPI
* QueriesAPI =
nullptr
;
52
IToolsContextTransactionsAPI
* TransactionsAPI =
nullptr
;
53
UInputRouter
* InputRouter =
nullptr
;
54
};
55
56
//
57
// Replace the internal functions that are called to create/destroy the sub-objects owned by the ITC.
58
// By doing this, clients of the ITF can provide their own subclass implementations, or do other
59
// custom setup/teardown as necessary. See comments above CreateInputRouterFunc below
60
//
61
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
SetCreateInputRouterFunc(
TUniqueFunction
<
UInputRouter
* (
const
FContextInitInfo
&)> Func);
62
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
SetCreateToolManagerFunc(
TUniqueFunction
<
UInteractiveToolManager
* (
const
FContextInitInfo
&)> Func);
63
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
SetCreateToolTargetManagerFunc(
TUniqueFunction
<
UToolTargetManager
* (
const
FContextInitInfo
&)> Func);
64
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
SetCreateGizmoManagerFunc(
TUniqueFunction
<
UInteractiveGizmoManager
* (
const
FContextInitInfo
&)> Func);
65
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
SetCreateContextStoreFunc(
TUniqueFunction
<
UContextObjectStore
* (
const
FContextInitInfo
&)> Func);
66
67
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
SetShutdownInputRouterFunc(
TUniqueFunction
<
void
(
UInputRouter
*)> Func);
68
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
SetShutdownToolManagerFunc(
TUniqueFunction
<
void
(
UInteractiveToolManager
*)> Func);
69
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
SetShutdownToolTargetManagerFunc(
TUniqueFunction
<
void
(
UToolTargetManager
*)> Func);
70
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
SetShutdownGizmoManagerFunc(
TUniqueFunction
<
void
(
UInteractiveGizmoManager
*)> Func);
71
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
SetShutdownContextStoreFunc(
TUniqueFunction
<
void
(
UContextObjectStore
*)> Func);
72
78
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
Initialize
(
IToolsContextQueriesAPI
* QueriesAPI,
IToolsContextTransactionsAPI
* TransactionsAPI);
79
81
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
Shutdown
();
82
83
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
DeactivateActiveTool(
EToolSide
WhichSide,
EToolShutdownType
ShutdownType);
84
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
DeactivateAllActiveTools(
EToolShutdownType
ShutdownType);
85
86
INTERACTIVETOOLSFRAMEWORK_API
bool
CanStartTool(
EToolSide
WhichSide,
const
FString&
ToolTypeIdentifier
)
const
;
87
INTERACTIVETOOLSFRAMEWORK_API
bool
HasActiveTool(
EToolSide
WhichSide)
const
;
88
INTERACTIVETOOLSFRAMEWORK_API
FString GetActiveToolName(
EToolSide
WhichSide)
const
;
89
INTERACTIVETOOLSFRAMEWORK_API
bool
ActiveToolHasAccept(
EToolSide
WhichSide)
const
;
90
INTERACTIVETOOLSFRAMEWORK_API
bool
CanAcceptActiveTool(
EToolSide
WhichSide)
const
;
91
INTERACTIVETOOLSFRAMEWORK_API
bool
CanCancelActiveTool(
EToolSide
WhichSide)
const
;
92
INTERACTIVETOOLSFRAMEWORK_API
bool
CanCompleteActiveTool(
EToolSide
WhichSide)
const
;
93
INTERACTIVETOOLSFRAMEWORK_API
bool
StartTool(
EToolSide
WhichSide,
const
FString&
ToolTypeIdentifier
);
94
INTERACTIVETOOLSFRAMEWORK_API
void
EndTool(
EToolSide
WhichSide,
EToolShutdownType
ShutdownType);
95
INTERACTIVETOOLSFRAMEWORK_API
bool
IsToolActive(
EToolSide
WhichSide,
const
FString
ToolIdentifier
)
const
;
96
97
public
:
98
// forwards message to OnToolNotificationMessage delegate
99
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
PostToolNotificationMessage(
const
FText
& Message);
100
INTERACTIVETOOLSFRAMEWORK_API
virtual
void
PostToolWarningMessage(
const
FText
& Message);
101
102
DECLARE_MULTICAST_DELEGATE_OneParam
(
FToolsContextToolNotification
,
const
FText
&);
103
FToolsContextToolNotification
OnToolNotificationMessage
;
104
FToolsContextToolNotification
OnToolWarningMessage
;
105
106
public
:
108
UPROPERTY
()
109
TObjectPtr
<
UInputRouter
> InputRouter;
110
112
UPROPERTY
()
113
TObjectPtr
<
UToolTargetManager
> TargetManager;
114
116
UPROPERTY
()
117
TObjectPtr
<
UInteractiveToolManager
> ToolManager;
118
120
UPROPERTY
()
121
TObjectPtr
<
UInteractiveGizmoManager
> GizmoManager;
122
127
UPROPERTY
()
128
TObjectPtr
<
UContextObjectStore
> ContextObjectStore;
129
130
protected
:
131
132
// Initialize() calls these functions to create the main child objects needed to operate
133
// the Tools Framework - InputRouter, ToolManager, GizmoManager, TargetManager, ContextStore.
134
// Default implementations are set up in the UInteractiveToolsContext() constructor, however
135
// users of the framework are free to replace these with subclasses, or do more complex
136
// initialization, by replacing these functions with their own versions before calling Initialize().
137
// (the same could be accomplished by subclassing and overriding Initialize(), however using these
138
// lambda functions will be a safer alternative in many cases)
139
TUniqueFunction
<
UInputRouter
* (const
FContextInitInfo
&)> CreateInputRouterFunc;
140
TUniqueFunction
<
UInteractiveToolManager
* (const
FContextInitInfo
&)> CreateToolManagerFunc;
141
TUniqueFunction
<
UToolTargetManager
* (const
FContextInitInfo
&)> CreateToolTargetManagerFunc;
142
TUniqueFunction
<
UInteractiveGizmoManager
* (const
FContextInitInfo
&)> CreateGizmoManagerFunc;
143
TUniqueFunction
<
UContextObjectStore
* (const
FContextInitInfo
&)> CreateContextStoreFunc;
144
145
// Analogous to the CreateX() functions above, these function are called by Shutdown()
146
// to terminate and clean up after the various elements.
147
TUniqueFunction
<
void
(
UInputRouter
*)> ShutdownInputRouterFunc;
148
TUniqueFunction
<
void
(
UInteractiveToolManager
*)> ShutdownToolManagerFunc;
149
TUniqueFunction
<
void
(
UToolTargetManager
*)> ShutdownToolTargetManagerFunc;
150
TUniqueFunction
<
void
(
UInteractiveGizmoManager
*)> ShutdownGizmoManagerFunc;
151
TUniqueFunction
<
void
(
UContextObjectStore
*)> ShutdownContextStoreFunc;
152
153
154
// todo: deprecate and remove this, can now be accomplished via CreateToolManagerFunc()
155
UPROPERTY
()
156
TSoftClassPtr
<
UInteractiveToolManager
> ToolManagerClass;
157
};
EAnalyticsSessionShutdownType::Shutdown
@ Shutdown
CoreMinimal.h
Function.h
StaticCastSharedRef
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition
SharedPointer.h:127
Delegate.h
EPackageAutoSaveType::Transient
@ Transient
InteractiveGizmoManager.h
InteractiveToolManager.h
EToolSide
EToolSide
Definition
InteractiveToolManager.h:20
InteractiveTool.h
EToolShutdownType
EToolShutdownType
Definition
InteractiveTool.h:45
ObjectMacros.h
UPROPERTY
#define UPROPERTY(...)
UObject definition macros.
Definition
ObjectMacros.h:744
GENERATED_BODY
#define GENERATED_BODY(...)
Definition
ObjectMacros.h:765
UCLASS
#define UCLASS(...)
Definition
ObjectMacros.h:776
ObjectPtr.h
Object.h
ESlateAttributeBindAction::Initialize
@ Initialize
SoftObjectPtr.h
UObjectGlobals.h
UnrealString.h
FText
Definition
Text.h:385
IToolsContextQueriesAPI
Definition
ToolContextInterfaces.h:254
IToolsContextTransactionsAPI
Definition
ToolContextInterfaces.h:360
TSoftClassPtr
Definition
SoftObjectPtr.h:763
TUniqueFunction
Definition
FunctionFwd.h:19
UContextObjectStore
Definition
ContextObjectStore.h:25
UInputRouter
Definition
InputRouter.h:39
UInteractiveGizmoManager
Definition
InteractiveGizmoManager.h:40
UInteractiveToolManager
Definition
InteractiveToolManager.h:79
UInteractiveToolsContext
Definition
InteractiveToolsContext.h:39
UInteractiveToolsContext::OnToolWarningMessage
FToolsContextToolNotification OnToolWarningMessage
Definition
InteractiveToolsContext.h:104
UInteractiveToolsContext::OnToolNotificationMessage
FToolsContextToolNotification OnToolNotificationMessage
Definition
InteractiveToolsContext.h:103
UInteractiveToolsContext::DECLARE_MULTICAST_DELEGATE_OneParam
DECLARE_MULTICAST_DELEGATE_OneParam(FToolsContextToolNotification, const FText &)
UObject
Definition
Object.h:95
UToolTargetManager
Definition
ToolTargetManager.h:37
TObjectPtr
Definition
ObjectPtr.h:488
UInteractiveToolsContext::FContextInitInfo
Definition
InteractiveToolsContext.h:49
Engine
Source
Runtime
InteractiveToolsFramework
Public
InteractiveToolsContext.h
Generated by
1.9.8