I want to create a new object. object’s type is passed to a function. And I want for returning parameter to be casted in correct class.
Now I have something like this:
void UMyCreator::CreateMyObject(const TSubclassOf<class UMyObject> MyType, UFileObject*& MyObject)
{
MyObject = NewObject<UMyObject>(this, MyType);
}
And I must to do cast in blueprints every time. It is not comfortable. Please help.
This might be more complicated then you expected, it’s custom node made from UK2Node, they are quite low level and you would need to even minor things (this may include compilation of VM code). It’s importnet to understand that those nodes are actully more related to UI and it’s tied to SGraphEditor widget and main job of those nodes is to hold and represent visually data and make that data turn in to something, in this case VM code.Also worth mention is nodes oyu make with “BlueprintCallable” and sucj are also UK2Node UK2Node_CallFunction and yes that means you cna have single node class act as multiple diffrent nodes.
There is 0 documentation (aside of API refrence) for this so best way to learn is to check source code:
https://github.com/EpicGames/UnrealEngine/blob/dff3c48be101bb9f84633a733ef79c91c38d9542/Engine/Source/Editor/BlueprintGraph/Private/K2Node_SpawnActor.cpp
https://github.com/EpicGames/UnrealEngine/blob/dff3c48be101bb9f84633a733ef79c91c38d9542/Engine/Source/Editor/BlueprintGraph/Private/K2Node_SpawnActorFromClass.cpp
I don’t think there other way, there lot of not documented specifiers and meta data things maybe you may find something
Thank you. I understood. Anyway it’s not worth it for me.