I need help because I can´t find this anywhere.
I want to call some functions from the Kismet Rendering Library from code.
But they always expect a
UObject* WorldContextObject! What is this and how can I get it?
I tried the following code after I searched for WorldContext, but it does not work =(
UObject* WorldContext = GEditor->GetEditorWorldContext();
UKismetRenderingLibrary::BeginDrawCanvasToRenderTarget(WorldContext, TextureTarget, Canvas, Size, Context);
FWorldContext cannot be converted to a
UObject. So what exactly does the Kismet Library want??
Thanks for any help!
UObject* WorldContextObject is just any
UObject the Static function can get the
UWorld from. So if you’re calling it from an
AActor, giving it
this would do.
UObject* someValidWorldContext = this; // assuming you're calling this on a UObject and not some abstract class.
static functions which are called BlueprintCallable, which require a WorldContextObject, doesn’t show it in blueprint because they have a meta specifier
meta = (WorldContext = "WorldContextObject") which lets them retrieve world from whatever actor they’re in, basically auto fills the world context with
Ah thanks for the answer.
Does it need to be an Actor, or is a Component equivalent?
Because my class is derived from SceneCaptureComponent2D. And I already tried calling the Kismet function with
this, but it did not work - I thought it was because of the wrong WorldContext Object…
The goal is to get the UWorld. And Components aren’t derived from AActor, but from ActorComponent.
In this case i would use “GetOwner()” instead of “this”. assuming the owner is an Actor though.
this works fine.
But I was calling it with the TextureTarget not being initialized, which was the reason the Kismet function failed. And appearantly I did a really bad job at debugging, thats why I did not find out earlier xD
But thanks for you explanation! I did really get confused about this though