I’m fairly new to Unreal so please excuse my ignorance.
I’m trying to load a proprietary model format from disk at run time and I’ve been able to get the model to load successfully when I initiate it in the constructor, which is great. I’d like to be able to load and unload models at will, so my question is what’s the best way to dynamically load these models from disk at run time?
What I’m running up against is my model only seems to render if I create the UProceduralMeshComponent it in the constructor, which is fine, but each model has a different name so one option would be to pass the name of the model into the constructor. Is there a way to create a constructor that takes a string and initialize my object from a blueprint and pass in a string?
Another option is to create a loadModel function that takes a string, but for some reason when I try to use NewObject or ConstructObject and execute the code on BeginPlay my model never renders. Whereas if I execute the same code in the constructor, but instead of using NewObject or ConstructObject I use CreateDefaultSubobject it renders fine.
Is there a trick to using UProceduralMeshComponent and NewObject? Or alternatively is there a way to spawn a new object using a blueprint and pass in a string as a parameter?
Thanks in advance.