How do I provide a UClass reference to a BlueprintNativeEvent?

Hi,

I made a C++ BlueprintNativeEvent like this:

UFUNCTION(BlueprintNativeEvent, Category = "External")
void CreateActor(int32 identifier, const UClass& klass, const TArray<uint8>& initialState);

And I call it like this:

UObject* ClassPackage = ANY_PACKAGE;
UClass* uClass = FindObject<UClass>(ClassPackage, klass);
CreateActor((int32)actorId, *uClass, actorState);

But when I compile it gives this exception:

Missing '*' in Expected a pointer type

Is this not allowed? I have other events that give pointers to TArrays and FStrings, why not UClass?

My ulterior objective is to create an actor with this string I got. If I could do that in blueprint that would be fine as well, but I couldn’t find a way to find the class with a string in blueprints.

Thanks!

your uClass is “already” a pointer, would not just shoot it without the preffixed * suffice? :confused:

CreateActor((int32)actorId, uClass, actorState);

unfortunately not, the function CreateActor takes a UClass&, so I need the * to get the address. I’m not very good at c++, but I’m sure this is the way it’s supposed to be. Something in Unreal Engine is disallowing it.

Wait… You’re trying to get a Class with FindObject instead of FindClass…

I never got this method (FindClass) to work, but I think you should try until get it working OR use the FindObject() to load a real object (that’s what it’s used for) and after use its ::StaticClass property on your CreateActor Class parameter.

I did a hack to make this work (with a StaticLoad), but if you are trying to make this to Widgets NIck from UMG team said to don’t do so.

Look my code here:

link text