UActorComponent::GetScene
#include "Components/ActorComponent.h"
Access: public
Specifiers: const
Description
Returns the rendering scene (FSceneInterface) associated with this component's world. Used to submit low-level rendering commands or query scene-level rendering state.
Caveats & Gotchas
- • Returns nullptr if the component is not registered in a world or if the world has no renderer (e.g. in unit tests or during early engine initialization).
- • FSceneInterface is a renderer-internal type; calling methods on it from game code requires understanding render thread synchronization — most game code should use higher-level UPrimitiveComponent APIs instead.
- • Do not cache the returned pointer across frames — the scene can be torn down and recreated (e.g. during world transitions).
Signature
ENGINE_API class FSceneInterface* GetScene() const; Return Type
class FSceneInterface* Example
Retrieve the scene for a custom render pass C++
void UMyRenderComponent::AddCustomRenderProxy()
{
FSceneInterface* Scene = GetScene();
if (Scene)
{
// Enqueue scene proxy addition via render thread command
ENQUEUE_RENDER_COMMAND(AddProxy)([Scene, this](FRHICommandListImmediate&)
{
Scene->AddPrimitive(MySceneProxy);
});
}
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?