You are viewing documentation for v1.1. Switch to current version โ†’

๐Ÿงญ Base World Context UObject

Short Description

Abstract base class for UObjects that need stable access to a UWorld instance via a cached fallback owner.

Long Description

UGorgeousBaseWorldContextUObject provides a small convenience layer for UObjects that need to resolve GetWorld() reliably. It stores a weak fallback owner (set with SetFallbackOwner) and overrides GetWorld() to return the appropriate UWorld based on the cached owner. Use this as a base when your UObject may be created outside a normal actor/component hierarchy but still requires world access.

๐Ÿš€ Features

  • Cached fallback owner pattern for reliable GetWorld() resolution.
  • Blueprint-callable getters/setters for the fallback owner.
  • Safe for use in editor and runtime contexts when a world is required.

SetFallbackOwner

Sets a weak cached owner used as an absolute fallback when resolving GetWorld(). The method is const but mutates a mutable weak pointer internally to allow call-sites to set a fallback owner from const contexts.

Parameter Name Type Description
NewFallbackOwner UObject* The object to cache as the fallback owner. It must be able to resolve a valid GetWorld() call.
// From some const accessor that needs to ensure a world exists
MyObj->SetFallbackOwner(SomeActor);

GetFallbackOwner

Returns the currently cached fallback owner, or nullptr if none is set or if the owner has been garbage collected.

UObject* Owner = MyObj->GetFallbackOwner();
if (Owner)
{
    UWorld* World = Owner->GetWorld();
}

GetWorld

Override of UObject::GetWorld() that first attempts to resolve the world from the object's normal outer/context. If that fails it falls back to the cached FallbackOwner and returns that owner's GetWorld() result. This provides more robust world resolution for objects created in nonstandard contexts.

UWorld* World = MyObj->GetWorld();
if (World)
{
    // safe to run world-scoped logic
}