Skip to content

UViewportWorldStatics

#include <ViewportWorlds/Public/Global/ViewportWorldStatics.h>
class UViewportWorldStatics

Defined in ViewportWorldStatics.h:17

Inherits: UBlueprintFunctionLibrary

---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UViewportWorldStatics["UViewportWorldStatics"]
  class UBlueprintFunctionLibrary["UBlueprintFunctionLibrary"]
  UBlueprintFunctionLibrary <|-- UViewportWorldStatics
---
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.

ReturnNameDescription
AActor *SpawnActorForWorldHandle staticSpawns 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.
voidOnWorldUnloaded staticTriggers the given event when the world handle calls Unload World. See also: UViewportWorldStatics::UnloadWorldHandle
voidAddWidgetToHandle staticAdds the given widget to the viewport. If the given world handle is not valid this works the same as Widget->AddToViewport
boolRemoveWidgetFromHandle staticRemoves the given widget (if it was added before) from viewport.
voidClearAllWidgetsFromHandle staticClears all widget from viewport.
voidInitializeActorsForWorldHandle staticInitializes actors for given world handle if not done while loading world. If they are initialized, this function does nothing. See also: UViewportWorldWidget::LoadGameWorld
voidBeginPlayForWorldHandle staticCalls 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
voidUnloadWorldHandle staticUnloads the given world handle.
boolUpdateViewMode staticChanges the world view mode to a new one.
voidSetWorldTickForHandle staticToggles ticking for the world. This affects the entire world (of the handle) including all actors, objects as well.
boolExecuteCommandForHandle staticRuns command for the world in given handle. Not all commands are supported and returning true doesn’t mean the command was success either.
boolIsViewportWorldHandleValid staticReturns true if the given handle is valid. This typically means that there is an actual world for the handle.
boolBelongsToSecondaryWorld staticReturns true if the given object or actor exists in the viewport world instead of the main game world.
AGameModeBase *GetGameModeFromHandle staticReturns game mode from handle.
AGameStateBase *GetGameStateFromHandle staticReturns game state from handle.
const FViewportWorldHandle *FindViewportWorldHandlePtr staticFind the pointer to the viewport world handle associated with the specified target world.
boolAddSlateWidgetToHandle staticAdds a Slate widget to a viewport world handle.
boolRemoveSlateWidgetFromHandle staticRemoves the specified Slate widget from the given viewport world handle.

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.

  • WorldHandle Reference to the world handle.

  • ActorClass Obvious right? This is the actor you want to spawn.

  • SpawnTransform Location, rotation and scale for your target actor.

  • CollisionHandlingMethod Defines available strategies for handling the case where an actor is spawned in such a way that it penetrates blocking collision

  • TransformScaleMethod Determines how the transform being passed into actor spawning methods interact with the actor’s default root component.

  • Owner Set an owner for the newly spawned actor.

Returns a valid actor if the spawning was successful.


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

  • WorldHandle World handle to listen to.

  • OnWorldUnloaded Event that should execute when the world unloads from given handle.


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

  • WorldContextObject World object.

  • WorldHandle World to add widget to.

  • Widget Target widget to add. Must not be null.

  • ZOrder Larger ZOrder will draw above others with smaller ZOrder. Same ZOrder between different widget will simply draw in the order they were added.


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.

  • WorldHandle World to remove widget from.

  • Widget Widget to remove.

True if the widget was removed successfully.


static

static void ClearAllWidgetsFromHandle(const FViewportWorldHandle & WorldHandle)

Defined in ViewportWorldStatics.h:93 Clears all widget from viewport.

  • WorldHandle World to remove all widgets from.

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

  • WorldHandle World handle to initialize

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

  • WorldHandle World handle to begin play

static

static void UnloadWorldHandle(const UObject * WorldContextObject, FViewportWorldHandle & WorldHandle)

Defined in ViewportWorldStatics.h:117 Unloads the given world handle.

  • WorldContextObject World object.

  • WorldHandle World handle that should be unloaded


static

static bool UpdateViewMode(const FViewportWorldHandle & WorldHandle, const EViewportWorldViewMode NewViewMode)

Defined in ViewportWorldStatics.h:126 Changes the world view mode to a new one.

  • WorldHandle World handle to update view mode for.

  • NewViewMode New view mode

True if the view mode was changed.


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.

  • WorldHandle Target world handle

  • bEnabled True to enable ticking. False otherwise.


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.

  • WorldHandle Target world handle

  • Command Command to run. Not all commands are supported though.

True if the command was executed. This doesn’t mean the command actually worked.


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.

  • TestHandle Handle to check

True if the given handle is valid.


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.

  • Target Target Object/Actor to check

True if the object/actor exists in secondary world.


static

static AGameModeBase * GetGameModeFromHandle(const FViewportWorldHandle & WorldHandle)

Defined in ViewportWorldStatics.h:167 Returns game mode from handle.

  • WorldHandle Target handle.

Returns the game mode from given handle.


static

static AGameStateBase * GetGameStateFromHandle(const FViewportWorldHandle & WorldHandle)

Defined in ViewportWorldStatics.h:175 Returns game state from handle.

  • WorldHandle Target handle.

Returns game state from given handle.


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.

  • WorldContextObject The object that serves as the world context.

  • TargetWorld The target world for which to find the viewport world handle.

A pointer to the found viewport world handle, or nullptr if no handle is found.


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.

  • WorldContextObject The world context object to add the Slate widget to.

  • WorldHandle The viewport world handle to add the Slate widget to.

  • WidgetContent The Slate widget content to add.

  • ZOrder The Z order of the added widget.

true if the widget was successfully added, false otherwise.


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.

  • WorldHandle The handle of the viewport world from which the widget should be removed.

  • SlateWidget The Slate widget to be removed from the viewport world.

Returns true if the removal was successful, false otherwise.