I have multiple blueprint classes in different folders in the content browser. I wish to make a reference to a blueprint class dynamically from a string in C++, how would I achieve this?
The string is dynamic so the reference needs to be set in runtime (So constructor helpers wont do since there are a lot of blueprints and making references to each one in the constructor portion of the class wouldn’t be either modular and a big waste of time, not to mention adding a reference each time i make a blueprint).
All the blueprints are parented from a C++ class.
I was thinking along the line of a get class by name function but can’t seem to find something like that in C++.
I have tried the function but to no avail. The function always returns Null no matter what ClassName i specify. I tried the blueprint name, the reference from the content browser, and more but no luck.
That still does not answer my question. The reference (“Texture2D’/Game/UI/HealthBar.HealthBar’”) has to be dynamic, and this operation is only doable in the constructor. I want to build a reference during runtime, not on construction of the editor.
You have the whole engine code, you can put a breakpoint in one of the places listed by me or search them yourself, then you will learn how use this functions:)
FindObject with Uclass finally worked. Did not know I had to append a _C at the end that was what I was missing, Thanks for bearing with me on this one.
Can you give an example of how you wrote out the blueprint class name?
AH! I got it. If your blueprint reference looks like this:
Blueprint’/Game/Environments/AsteroidBaseMocks/AsteroidHall_L/Base_A_AsteroidHall_L_Straight.Base_A_AsteroidHall_L_Straight’
Then the string is:
/Game/Environments/AsteroidBaseMocks/AsteroidHall_L/Base_A_AsteroidHall_L_Straight.Base_A_AsteroidHall_L_Straight_C
Take off the Blueprint part and the single quotes and end it in _C