MultiWorld  1.0.0
Static Public Member Functions | List of all members
UMultiWorldStatics Class Reference

Static class with MultiWorld functions that can be called from both Blueprint and C++. More...

#include <MultiWorldStatics.h>

Inheritance diagram for UMultiWorldStatics:

Static Public Member Functions

static bool AreWorldsEquals (const FMultiWorldHandle &InWorldHandleA, const FMultiWorldHandle &InWorldHandleB)
 Return true if the two world handle(s) are equals (they refer to the same world), false otherwise. More...
 
static void EndWorld (const UObject *WorldContextObject, const FMultiWorldHandle &InWorldHandle)
 Call the EndPlay to the input World and to all its actors; The World and all actors are destroyed. More...
 
static void ExecuteConsoleCommandInWorld (const FMultiWorldHandle &InWorldHandle, const FString &Command)
 Executes a console command on a specific world. More...
 
static FMultiWorldHandle GetActiveWorldHandle (const UObject *WorldContextObject)
 Return the world handle of the active World. More...
 
static class AActor * GetActorOfClass (const FMultiWorldHandle &InWorldHandle, TSubclassOf< AActor > ActorClass)
 Find the first Actor in the world of the specified class. More...
 
static void GetAllActorsOfClass (const FMultiWorldHandle &InWorldHandle, TSubclassOf< AActor > ActorClass, TArray< AActor * > &OutActors)
 Find all Actors in the world of the specified class. More...
 
static void GetAllActorsOfClassWithTag (const FMultiWorldHandle &InWorldHandle, TSubclassOf< AActor > ActorClass, FName Tag, TArray< AActor * > &OutActors)
 Find all Actors in the world of the specified class with the specified tag. More...
 
static void GetAllActorsWithInterface (const FMultiWorldHandle &InWorldHandle, TSubclassOf< UInterface > Interface, TArray< AActor * > &OutActors)
 Find all Actors in the world with the specified interface. More...
 
static void GetAllActorsWithTag (const FMultiWorldHandle &InWorldHandle, FName Tag, TArray< AActor * > &OutActors)
 Find all Actors in the world with the specified tag. More...
 
static void GetAllObjectsWithInterface (const FMultiWorldHandle &InWorldHandle, TSubclassOf< UInterface > Interface, TArray< UObject * > &OutObjects)
 Find all UObject(s) in the world with the specified interface. More...
 
static FMultiWorldHandle GetMainWorldHandle (const UObject *WorldContextObject)
 Return the main world handle. More...
 
static FMultiWorldHandle GetThisWorldHandle (const UObject *WorldContextObject)
 Return the world handle where the caller lives. More...
 
static FMultiWorldHandle GetWorldHandleByName (const UObject *WorldContextObject, FName WorldName)
 Return the world handle of the world with the given name if found or an invalid handle otherwise. More...
 
static void InitializeWorld (const UObject *WorldContextObject, const FMultiWorldHandle &InWorldHandle)
 Setup the input World for playing; Actors are intialized, BeginPlay is called etc... More...
 
static bool IsValidHandle (const UObject *WorldContextObject, const FMultiWorldHandle &InWorldHandle)
 Return true if the input world handle is valid, false otherwise. More...
 
static FMultiWorldHandle LoadWorld (const UObject *WorldContextObject, TSoftObjectPtr< UWorld > MapAsset, FMultiWorldLoadParameters InParams)
 Synchronously load a World into memory. More...
 
static void LoadWorldAsync (const UObject *WorldContextObject, TSoftObjectPtr< UWorld > MapAsset, FMultiWorldLoadParameters InParams)
 Asynchronously load a World into memory. More...
 
static bool ReturnToMainWorld (const UObject *WorldContextObject)
 Travel the local players to the main world. More...
 
static void SetAutoHandleWidgetsForMainWorld (const UObject *WorldContextObject, bool bAutoHandleWidgets)
 Sets whenever the UMG main world widgets must be handled automatically or not (shown when the world is active, hidden when the world is not). More...
 
static void SetPhysicsActorTransform (AActor *Actor, const FTransform &NewTransform, ETeleportType Teleport=ETeleportType::ResetPhysics)
 Set the Actor transform, moving also all attached physics bodies as a single entity. More...
 
static void SetShouldTickWhenInBackground (const UObject *WorldContextObject, const FMultiWorldHandle &InWorldHandle, bool bShouldTick)
 Sets whether or not the input world is ticked by the engine when it is in background (when not in play). More...
 
static AActor * SpawnActorInWorld (const UObject *WorldContextObject, TSubclassOf< class AActor > ActorClass, const FMultiWorldHandle &InWorldHandle, const FTransform &SpawnTransform, ESpawnActorCollisionHandlingMethod CollisionHandlingOverride, AActor *Owner)
 Create an actor and place it in the input world. More...
 
static bool SwitchWorld (const UObject *WorldContextObject, const FMultiWorldHandle &InWorldHandle)
 Change the Active World, travelling the local players to the input world. More...
 
static void TransferActorToWorld (const UObject *WorldContextObject, AActor *InActor, const FMultiWorldHandle &InWorldHandle, const FMultiWorldTransferActorParameters &Options)
 Transfer the input actor from its actual world to the input one. More...
 

Detailed Description

Static class with MultiWorld functions that can be called from both Blueprint and C++.

Few extra features (mainly Delegates) are available using the UMultiWorldManager subsystem.

Member Function Documentation

◆ AreWorldsEquals()

static bool UMultiWorldStatics::AreWorldsEquals ( const FMultiWorldHandle InWorldHandleA,
const FMultiWorldHandle InWorldHandleB 
)
static

Return true if the two world handle(s) are equals (they refer to the same world), false otherwise.

Parameters
[in]InWorldHandleAfirst world handle to compare
[in]InWorldHandleBsecond world handle to compare

◆ EndWorld()

static void UMultiWorldStatics::EndWorld ( const UObject *  WorldContextObject,
const FMultiWorldHandle InWorldHandle 
)
static

Call the EndPlay to the input World and to all its actors; The World and all actors are destroyed.

The input world handle is not more valid after.

Parameters
[in]WorldContextObjectthe world context object
InWorldHandlethe world handle

◆ ExecuteConsoleCommandInWorld()

static void UMultiWorldStatics::ExecuteConsoleCommandInWorld ( const FMultiWorldHandle InWorldHandle,
const FString &  Command 
)
static

Executes a console command on a specific world.

Parameters
InWorldHandleThe handle of the world where to exec the command
CommandCommand to send to the console

◆ GetActiveWorldHandle()

static FMultiWorldHandle UMultiWorldStatics::GetActiveWorldHandle ( const UObject *  WorldContextObject)
static

Return the world handle of the active World.

Parameters
[in]WorldContextObjectthe world context object

◆ GetActorOfClass()

static class AActor* UMultiWorldStatics::GetActorOfClass ( const FMultiWorldHandle InWorldHandle,
TSubclassOf< AActor >  ActorClass 
)
static

Find the first Actor in the world of the specified class.

This is a slow operation, use with caution e.g. do not use every frame.

Parameters
InWorldHandleThe handle of the world where find the actor.
ActorClassClass of Actor to find. Must be specified or result will be empty.
Returns
Actor of the specified class.

◆ GetAllActorsOfClass()

static void UMultiWorldStatics::GetAllActorsOfClass ( const FMultiWorldHandle InWorldHandle,
TSubclassOf< AActor >  ActorClass,
TArray< AActor * > &  OutActors 
)
static

Find all Actors in the world of the specified class.

This is a slow operation, use with caution e.g. do not use every frame.

Parameters
InWorldHandleThe handle of the world where find the actors.
ActorClassClass of Actor to find. Must be specified or result array will be empty.
OutActorsOutput array of Actors of the specified class.

◆ GetAllActorsOfClassWithTag()

static void UMultiWorldStatics::GetAllActorsOfClassWithTag ( const FMultiWorldHandle InWorldHandle,
TSubclassOf< AActor >  ActorClass,
FName  Tag,
TArray< AActor * > &  OutActors 
)
static

Find all Actors in the world of the specified class with the specified tag.

This is a slow operation, use with caution e.g. do not use every frame.

Parameters
InWorldHandleThe handle of the world where find the actors.
TagTag to find. Must be specified or result array will be empty.
ActorClassClass of Actor to find. Must be specified or result array will be empty.
OutActorsOutput array of Actors of the specified tag.

◆ GetAllActorsWithInterface()

static void UMultiWorldStatics::GetAllActorsWithInterface ( const FMultiWorldHandle InWorldHandle,
TSubclassOf< UInterface >  Interface,
TArray< AActor * > &  OutActors 
)
static

Find all Actors in the world with the specified interface.

This is a slow operation, use with caution e.g. do not use every frame.

Parameters
InWorldHandleThe handle of the world where find the actors.
InterfaceInterface to find. Must be specified or result array will be empty.
OutActorsOutput array of Actors of the specified interface.

◆ GetAllActorsWithTag()

static void UMultiWorldStatics::GetAllActorsWithTag ( const FMultiWorldHandle InWorldHandle,
FName  Tag,
TArray< AActor * > &  OutActors 
)
static

Find all Actors in the world with the specified tag.

This is a slow operation, use with caution e.g. do not use every frame.

Parameters
InWorldHandleThe handle of the world where find the actors.
TagTag to find. Must be specified or result array will be empty.
OutActorsOutput array of Actors of the specified tag.

◆ GetAllObjectsWithInterface()

static void UMultiWorldStatics::GetAllObjectsWithInterface ( const FMultiWorldHandle InWorldHandle,
TSubclassOf< UInterface >  Interface,
TArray< UObject * > &  OutObjects 
)
static

Find all UObject(s) in the world with the specified interface.

This is a slow operation, use with caution e.g. do not use every frame.

Parameters
InWorldHandleThe handle of the world where find the actors.
InterfaceInterface to find. Must be specified or result array will be empty.
OutObjectsOutput array of UObject(s) of the specified interface.

◆ GetMainWorldHandle()

static FMultiWorldHandle UMultiWorldStatics::GetMainWorldHandle ( const UObject *  WorldContextObject)
static

Return the main world handle.

The main world is the world loaded by the Unreal Engine itself.

Parameters
[in]WorldContextObjectthe world context object

◆ GetThisWorldHandle()

static FMultiWorldHandle UMultiWorldStatics::GetThisWorldHandle ( const UObject *  WorldContextObject)
static

Return the world handle where the caller lives.

Technically it's the UWorld of the World Context Object implicitly passed by UE4 to the function.

Parameters
[in]WorldContextObjectthe world context object

◆ GetWorldHandleByName()

static FMultiWorldHandle UMultiWorldStatics::GetWorldHandleByName ( const UObject *  WorldContextObject,
FName  WorldName 
)
static

Return the world handle of the world with the given name if found or an invalid handle otherwise.

If two or more worlds have the same name, the first found is returned.

Parameters
[in]WorldContextObjectthe world context object
[in]WorldNamethe name of the world to looking for

◆ InitializeWorld()

static void UMultiWorldStatics::InitializeWorld ( const UObject *  WorldContextObject,
const FMultiWorldHandle InWorldHandle 
)
static

Setup the input World for playing; Actors are intialized, BeginPlay is called etc...

After you call this method, you can switch world calling SwitchWorld.

Parameters
[in]WorldContextObjectthe world context object
InWorldHandlethe world to setup; it should came from the function LoadWorld.

◆ IsValidHandle()

static bool UMultiWorldStatics::IsValidHandle ( const UObject *  WorldContextObject,
const FMultiWorldHandle InWorldHandle 
)
static

Return true if the input world handle is valid, false otherwise.

Parameters
[in]WorldContextObjectthe world context object
[in]InWorldHandlethe world handle to check

◆ LoadWorld()

static FMultiWorldHandle UMultiWorldStatics::LoadWorld ( const UObject *  WorldContextObject,
TSoftObjectPtr< UWorld >  MapAsset,
FMultiWorldLoadParameters  InParams 
)
static

Synchronously load a World into memory.

Be aware that the loaded world exists only on the local client and is not replicated.

Parameters
[in]WorldContextObjectthe world context object
MapAssetthe map asset where the World is located.
InParamsoptional params to customize the loading.
Returns
the loaded world handle if success, an invalid handle otherwise
See also
LoadWorldAsync() to load a world asynchronously.
MultiWorldLoadParameters to customize the loading.

◆ LoadWorldAsync()

static void UMultiWorldStatics::LoadWorldAsync ( const UObject *  WorldContextObject,
TSoftObjectPtr< UWorld >  MapAsset,
FMultiWorldLoadParameters  InParams 
)
static

Asynchronously load a World into memory.

Use the delegate UMultiWorldManager::OnAsyncLoadCompleted to be notified when the load is completed. Be aware that the loaded world exists only on the local client and is not replicated.

Attention
to work asynchronously, the project setting "Async Loading Thread Enabled" MUST be enabled (under section "Engine - Streaming") and project data MUST be cooked. You can also enable the flag adding in DefaultEngine.ini:
[/Script/Engine.StreamingSettings]
s.AsyncLoadingThreadEnable=true
Parameters
[in]WorldContextObjectthe world context object
MapAssetthe map asset where the World is located.
InParamsoptional params to customize the loading.
See also
LoadWorld() to load a world synchronously.
MultiWorldLoadParameters to customize the loading.

◆ ReturnToMainWorld()

static bool UMultiWorldStatics::ReturnToMainWorld ( const UObject *  WorldContextObject)
static

Travel the local players to the main world.

The main world is the world loaded by the Unreal Engine itself. If you call from the main world, the call doesn't have any effect.

Parameters
[in]WorldContextObjectthe world context object
Returns
true if succeeded, false otherwise

◆ SetAutoHandleWidgetsForMainWorld()

static void UMultiWorldStatics::SetAutoHandleWidgetsForMainWorld ( const UObject *  WorldContextObject,
bool  bAutoHandleWidgets 
)
static

Sets whenever the UMG main world widgets must be handled automatically or not (shown when the world is active, hidden when the world is not).

Parameters
[in]WorldContextObjectthe world context object
[in]bAutoHandleWidgetstrue if widgets are handled automatically for the main world, false otherwise.

◆ SetPhysicsActorTransform()

static void UMultiWorldStatics::SetPhysicsActorTransform ( AActor *  Actor,
const FTransform &  NewTransform,
ETeleportType  Teleport = ETeleportType::ResetPhysics 
)
static

Set the Actor transform, moving also all attached physics bodies as a single entity.

Parameters
ActorThe Actor to move.
NewTransformThe new transform.
TeleportHow we teleport the physics state (see AActor::SetActorTransform()).

◆ SetShouldTickWhenInBackground()

static void UMultiWorldStatics::SetShouldTickWhenInBackground ( const UObject *  WorldContextObject,
const FMultiWorldHandle InWorldHandle,
bool  bShouldTick 
)
static

Sets whether or not the input world is ticked by the engine when it is in background (when not in play).

Attention
You MUST NOT disable the background ticking of the Main World in a multi-player game.
Parameters
[in]WorldContextObjectthe world context object
InWorldHandlethe world handle for which to apply the setting
bShouldTickthe "tick-when-in-background" flag

◆ SpawnActorInWorld()

static AActor* UMultiWorldStatics::SpawnActorInWorld ( const UObject *  WorldContextObject,
TSubclassOf< class AActor >  ActorClass,
const FMultiWorldHandle InWorldHandle,
const FTransform &  SpawnTransform,
ESpawnActorCollisionHandlingMethod  CollisionHandlingOverride,
AActor *  Owner 
)
static

Create an actor and place it in the input world.

Parameters
[in]WorldContextObjectthe world context object
[in]ActorClassthe class to use to create the actor
[in]InWorldHandlethe world where to place the actor
[in]SpawnTransformthe absolute world transform of the new actor
[in]CollisionHandlingOverridethe strategy for handling the case of collision when the actor is spawned
[in]Ownerthe owner of the new actor
Returns
the new created actor

◆ SwitchWorld()

static bool UMultiWorldStatics::SwitchWorld ( const UObject *  WorldContextObject,
const FMultiWorldHandle InWorldHandle 
)
static

Change the Active World, travelling the local players to the input world.

Secondary Worlds are not replicated.

All actors implementing the interface IMultiWorldActorInterface are notified accordingly to the interface.

The delegate UMultiWorldManager::OnWorldSwitched is notified.

UMG widgets are managed accordingly to the configuration (see FMultiWorldLoadParameters::bAutoHandleWidgets and SetAutoHandleWidgetsForMainWorld()).

Parameters
[in]WorldContextObjectthe world context object
InWorldHandlethe world handle where to go
Returns
true if succeeded, false otherwise

◆ TransferActorToWorld()

static void UMultiWorldStatics::TransferActorToWorld ( const UObject *  WorldContextObject,
AActor *  InActor,
const FMultiWorldHandle InWorldHandle,
const FMultiWorldTransferActorParameters Options 
)
static

Transfer the input actor from its actual world to the input one.

It's not network-replicated.

Attention
While the method UMultiWorldStatics::TransferActorToWorld() provides a convenient way to transfer an actor between different UWorld instances, and its implementation is generic enough to manage most common cases, particular actor setups or advanced uses could require a different and manual procedure. In this case, the suggested approach is to serialize the actor from the source World into a temporary buffer, destroy the actor and create a new instance in the destination World (e.g. using UMultiWorldStatics::SpawnActorInWorld()), finally restoring its state from the serialized data.
Parameters
[in]WorldContextObjectthe world context object
InActorthe actor to transfer
InWorldHandlethe new world of the input actor
OptionsOptions to customize the transfer (including setting a final transform for the actor).

The documentation for this class was generated from the following file: