UViewportWorldStatics
#include <ViewportWorlds/Public/Global/ViewportWorldStatics.h>class UViewportWorldStaticsDefined in ViewportWorldStatics.h:17
Inherits:
UBlueprintFunctionLibrary
Inheritance diagram
Section titled “Inheritance diagram”---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
class UViewportWorldStatics["UViewportWorldStatics"]
class UBlueprintFunctionLibrary["UBlueprintFunctionLibrary"]
UBlueprintFunctionLibrary <|-- UViewportWorldStatics
Class detail
Section titled “Class detail”---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
class UViewportWorldStatics {
+SpawnActorForWorldHandle(FViewportWorldHandle &WorldHandle, const TS AActor *
+OnWorldUnloaded(FViewportWorldHandle &WorldHandle, const FO
+AddWidgetToHandle(const UObject *WorldContextObject, const FV
+RemoveWidgetFromHandle(const FViewportWorldHandle &WorldHandle, UU bool
+ClearAllWidgetsFromHandle(const FViewportWorldHandle &WorldHandle)
+InitializeActorsForWorldHandle(FViewportWorldHandle &WorldHandle)
+BeginPlayForWorldHandle(FViewportWorldHandle &WorldHandle)
+UnloadWorldHandle(const UObject *WorldContextObject, FViewpor
+UpdateViewMode(const FViewportWorldHandle &WorldHandle, co bool
+SetWorldTickForHandle(const FViewportWorldHandle &WorldHandle, co
+ExecuteCommandForHandle(const FViewportWorldHandle &WorldHandle, co bool
+IsViewportWorldHandleValid(const FViewportWorldHandle &TestHandle) bool
+BelongsToSecondaryWorld(const UObject *Target) bool
+GetGameModeFromHandle(const FViewportWorldHandle &WorldHandle) AGameModeBase *
+GetGameStateFromHandle(const FViewportWorldHandle &WorldHandle) AGameStateBase *
+FindViewportWorldHandlePtr(const UObject *WorldContextObject, const TS const FViewportWorldHandle() *
+AddSlateWidgetToHandle(const UObject *WorldContextObject, const FV bool
+RemoveSlateWidgetFromHandle(const FViewportWorldHandle &WorldHandle, co bool
}
A static class that provides utility functions for working with viewport worlds.
This class provides functions for handling viewport worlds, including finding viewport world handles, spawning actors, adding widgets to viewports, initializing actors, and manipulating view modes and tick settings.
Public Static Methods
Section titled “Public Static Methods”| Return | Name | Description |
|---|---|---|
AActor * | SpawnActorForWorldHandle static | Spawns an actor for the given world handle. This function will ONLY return a valid actor if the following conditions are met: 1: ActorClass is valid. 2: Given world handle is valid. 3: Given world handle has actors initialized. If not initialized, call UViewportWorldStatics::InitializeActorsForWorldHandle 4: Given world handle has begun play. |
void | OnWorldUnloaded static | Triggers the given event when the world handle calls Unload World. See also: UViewportWorldStatics::UnloadWorldHandle |
void | AddWidgetToHandle static | Adds the given widget to the viewport. If the given world handle is not valid this works the same as Widget->AddToViewport |
bool | RemoveWidgetFromHandle static | Removes the given widget (if it was added before) from viewport. |
void | ClearAllWidgetsFromHandle static | Clears all widget from viewport. |
void | InitializeActorsForWorldHandle static | Initializes actors for given world handle if not done while loading world. If they are initialized, this function does nothing. See also: UViewportWorldWidget::LoadGameWorld |
void | BeginPlayForWorldHandle static | Calls begin play for given world handle if not done while loading world. If begin play was already called, this function does nothing. See also: UViewportWorldWidget::LoadGameWorld |
void | UnloadWorldHandle static | Unloads the given world handle. |
bool | UpdateViewMode static | Changes the world view mode to a new one. |
void | SetWorldTickForHandle static | Toggles ticking for the world. This affects the entire world (of the handle) including all actors, objects as well. |
bool | ExecuteCommandForHandle static | Runs command for the world in given handle. Not all commands are supported and returning true doesn’t mean the command was success either. |
bool | IsViewportWorldHandleValid static | Returns true if the given handle is valid. This typically means that there is an actual world for the handle. |
bool | BelongsToSecondaryWorld static | Returns true if the given object or actor exists in the viewport world instead of the main game world. |
AGameModeBase * | GetGameModeFromHandle static | Returns game mode from handle. |
AGameStateBase * | GetGameStateFromHandle static | Returns game state from handle. |
const FViewportWorldHandle * | FindViewportWorldHandlePtr static | Find the pointer to the viewport world handle associated with the specified target world. |
bool | AddSlateWidgetToHandle static | Adds a Slate widget to a viewport world handle. |
bool | RemoveSlateWidgetFromHandle static | Removes the specified Slate widget from the given viewport world handle. |
SpawnActorForWorldHandle
Section titled “SpawnActorForWorldHandle”static
static AActor * SpawnActorForWorldHandle(FViewportWorldHandle & WorldHandle, const TSubclassOf< AActor > ActorClass, const FTransform & SpawnTransform, const ESpawnActorCollisionHandlingMethod CollisionHandlingMethod = ESpawnActorCollisionHandlingMethod::Undefined, const ESpawnActorScaleMethod TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot, AActor * Owner = nullptr)Defined in ViewportWorldStatics.h:53 Spawns an actor for the given world handle. This function will ONLY return a valid actor if the following conditions are met: 1: ActorClass is valid. 2: Given world handle is valid. 3: Given world handle has actors initialized. If not initialized, call UViewportWorldStatics::InitializeActorsForWorldHandle 4: Given world handle has begun play.
Parameters
Section titled “Parameters”-
WorldHandleReference to the world handle. -
ActorClassObvious right? This is the actor you want to spawn. -
SpawnTransformLocation, rotation and scale for your target actor. -
CollisionHandlingMethodDefines available strategies for handling the case where an actor is spawned in such a way that it penetrates blocking collision -
TransformScaleMethodDetermines how the transform being passed into actor spawning methods interact with the actor’s default root component. -
OwnerSet an owner for the newly spawned actor.
Returns
Section titled “Returns”Returns a valid actor if the spawning was successful.
References
Section titled “References”OnWorldUnloaded
Section titled “OnWorldUnloaded”static
static void OnWorldUnloaded(FViewportWorldHandle & WorldHandle, const FOnWorldUnloaded & OnWorldUnloaded)Defined in ViewportWorldStatics.h:67 Triggers the given event when the world handle calls Unload World. See also: UViewportWorldStatics::UnloadWorldHandle
Parameters
Section titled “Parameters”-
WorldHandleWorld handle to listen to. -
OnWorldUnloadedEvent that should execute when the world unloads from given handle.
Referenced by
Section titled “Referenced by”References
Section titled “References”IsViewportWorldsEnabledOnWorldUnloadedOnWorldUnloadedDelegateVerboseWarning
AddWidgetToHandle
Section titled “AddWidgetToHandle”static
static void AddWidgetToHandle(const UObject * WorldContextObject, const FViewportWorldHandle & WorldHandle, UUserWidget * Widget, const int32 ZOrder = 0)Defined in ViewportWorldStatics.h:77 Adds the given widget to the viewport. If the given world handle is not valid this works the same as Widget->AddToViewport
Parameters
Section titled “Parameters”-
WorldContextObjectWorld object. -
WorldHandleWorld to add widget to. -
WidgetTarget widget to add. Must not be null. -
ZOrderLarger ZOrder will draw above others with smaller ZOrder. Same ZOrder between different widget will simply draw in the order they were added.
References
Section titled “References”RemoveWidgetFromHandle
Section titled “RemoveWidgetFromHandle”static
static bool RemoveWidgetFromHandle(const FViewportWorldHandle & WorldHandle, UUserWidget * Widget)Defined in ViewportWorldStatics.h:86 Removes the given widget (if it was added before) from viewport.
Parameters
Section titled “Parameters”-
WorldHandleWorld to remove widget from. -
WidgetWidget to remove.
Returns
Section titled “Returns”True if the widget was removed successfully.
References
Section titled “References”ClearAllWidgetsFromHandle
Section titled “ClearAllWidgetsFromHandle”static
static void ClearAllWidgetsFromHandle(const FViewportWorldHandle & WorldHandle)Defined in ViewportWorldStatics.h:93 Clears all widget from viewport.
Parameters
Section titled “Parameters”WorldHandleWorld to remove all widgets from.
References
Section titled “References”InitializeActorsForWorldHandle
Section titled “InitializeActorsForWorldHandle”static
static void InitializeActorsForWorldHandle(FViewportWorldHandle & WorldHandle)Defined in ViewportWorldStatics.h:101 Initializes actors for given world handle if not done while loading world. If they are initialized, this function does nothing. See also: UViewportWorldWidget::LoadGameWorld
Parameters
Section titled “Parameters”WorldHandleWorld handle to initialize
References
Section titled “References”BeginPlayForWorldHandle
Section titled “BeginPlayForWorldHandle”static
static void BeginPlayForWorldHandle(FViewportWorldHandle & WorldHandle)Defined in ViewportWorldStatics.h:109 Calls begin play for given world handle if not done while loading world. If begin play was already called, this function does nothing. See also: UViewportWorldWidget::LoadGameWorld
Parameters
Section titled “Parameters”WorldHandleWorld handle to begin play
References
Section titled “References”UnloadWorldHandle
Section titled “UnloadWorldHandle”static
static void UnloadWorldHandle(const UObject * WorldContextObject, FViewportWorldHandle & WorldHandle)Defined in ViewportWorldStatics.h:117 Unloads the given world handle.
Parameters
Section titled “Parameters”-
WorldContextObjectWorld object. -
WorldHandleWorld handle that should be unloaded
References
Section titled “References”UpdateViewMode
Section titled “UpdateViewMode”static
static bool UpdateViewMode(const FViewportWorldHandle & WorldHandle, const EViewportWorldViewMode NewViewMode)Defined in ViewportWorldStatics.h:126 Changes the world view mode to a new one.
Parameters
Section titled “Parameters”-
WorldHandleWorld handle to update view mode for. -
NewViewModeNew view mode
Returns
Section titled “Returns”True if the view mode was changed.
References
Section titled “References”SetWorldTickForHandle
Section titled “SetWorldTickForHandle”static
static void SetWorldTickForHandle(const FViewportWorldHandle & WorldHandle, const bool bEnabled)Defined in ViewportWorldStatics.h:134 Toggles ticking for the world. This affects the entire world (of the handle) including all actors, objects as well.
Parameters
Section titled “Parameters”-
WorldHandleTarget world handle -
bEnabledTrue to enable ticking. False otherwise.
References
Section titled “References”ExecuteCommandForHandle
Section titled “ExecuteCommandForHandle”static
static bool ExecuteCommandForHandle(const FViewportWorldHandle & WorldHandle, const FString Command)Defined in ViewportWorldStatics.h:143 Runs command for the world in given handle. Not all commands are supported and returning true doesn’t mean the command was success either.
Parameters
Section titled “Parameters”-
WorldHandleTarget world handle -
CommandCommand to run. Not all commands are supported though.
Returns
Section titled “Returns”True if the command was executed. This doesn’t mean the command actually worked.
References
Section titled “References”IsViewportWorldHandleValid
Section titled “IsViewportWorldHandleValid”static
static bool IsViewportWorldHandleValid(const FViewportWorldHandle & TestHandle)Defined in ViewportWorldStatics.h:151 Returns true if the given handle is valid. This typically means that there is an actual world for the handle.
Parameters
Section titled “Parameters”TestHandleHandle to check
Returns
Section titled “Returns”True if the given handle is valid.
References
Section titled “References”BelongsToSecondaryWorld
Section titled “BelongsToSecondaryWorld”static
static bool BelongsToSecondaryWorld(const UObject * Target)Defined in ViewportWorldStatics.h:159 Returns true if the given object or actor exists in the viewport world instead of the main game world.
Parameters
Section titled “Parameters”TargetTarget Object/Actor to check
Returns
Section titled “Returns”True if the object/actor exists in secondary world.
GetGameModeFromHandle
Section titled “GetGameModeFromHandle”static
static AGameModeBase * GetGameModeFromHandle(const FViewportWorldHandle & WorldHandle)Defined in ViewportWorldStatics.h:167 Returns game mode from handle.
Parameters
Section titled “Parameters”WorldHandleTarget handle.
Returns
Section titled “Returns”Returns the game mode from given handle.
References
Section titled “References”GetGameStateFromHandle
Section titled “GetGameStateFromHandle”static
static AGameStateBase * GetGameStateFromHandle(const FViewportWorldHandle & WorldHandle)Defined in ViewportWorldStatics.h:175 Returns game state from handle.
Parameters
Section titled “Parameters”WorldHandleTarget handle.
Returns
Section titled “Returns”Returns game state from given handle.
References
Section titled “References”FindViewportWorldHandlePtr
Section titled “FindViewportWorldHandlePtr”static
static const FViewportWorldHandle * FindViewportWorldHandlePtr(const UObject * WorldContextObject, const TSoftObjectPtr< UWorld > & TargetWorld)Defined in ViewportWorldStatics.h:188 Find the pointer to the viewport world handle associated with the specified target world.
This function searches for the viewport world handle that is associated with the specified target world. It utilizes the UViewportWorldSubsystem to retrieve the handle.
Parameters
Section titled “Parameters”-
WorldContextObjectThe object that serves as the world context. -
TargetWorldThe target world for which to find the viewport world handle.
Returns
Section titled “Returns”A pointer to the found viewport world handle, or nullptr if no handle is found.
Referenced by
Section titled “Referenced by”References
Section titled “References”AddSlateWidgetToHandle
Section titled “AddSlateWidgetToHandle”static
static bool AddSlateWidgetToHandle(const UObject * WorldContextObject, const FViewportWorldHandle & WorldHandle, const TSharedRef< SWidget > & WidgetContent, const int32 & ZOrder)Defined in ViewportWorldStatics.h:202 Adds a Slate widget to a viewport world handle.
This function adds the specified Slate widget content to the viewport world handle in the given world context object.
Parameters
Section titled “Parameters”-
WorldContextObjectThe world context object to add the Slate widget to. -
WorldHandleThe viewport world handle to add the Slate widget to. -
WidgetContentThe Slate widget content to add. -
ZOrderThe Z order of the added widget.
Returns
Section titled “Returns”true if the widget was successfully added, false otherwise.
References
Section titled “References”RemoveSlateWidgetFromHandle
Section titled “RemoveSlateWidgetFromHandle”static
static bool RemoveSlateWidgetFromHandle(const FViewportWorldHandle & WorldHandle, const TSharedRef< SWidget > & SlateWidget)Defined in ViewportWorldStatics.h:215 Removes the specified Slate widget from the given viewport world handle.
This function removes the specified Slate widget from the given viewport world handle. The viewport world handle is used to identify a specific viewport world where the widget is attached.
Parameters
Section titled “Parameters”-
WorldHandleThe handle of the viewport world from which the widget should be removed. -
SlateWidgetThe Slate widget to be removed from the viewport world.
Returns
Section titled “Returns”Returns true if the removal was successful, false otherwise.