Hello. I’m trying to make an InteractiveComponent, which creates class derived from UWidgetComponent. In this component I want to show widget created as UMG (this is a suggestion to the player about interacting with the object). So I need to reference to one widget blueprint class in every instance of my InteractiveComponent.
I had 4 possible solutions:
- Mark as UProperty field of type TSubclassOf. But this way I would need to do this for each InteractiveComponent, which increases the likelihood of errors, and I think this is an illogical and inconvenient solution.
- Hardcode path to blueprint class. This is also a bad solution because class paths may change and you will have to manually change them.
- Create a GameSingleton class. This solution is already better, since it does not have the disadvantages listed above. But the disadvantage of this solution is that it is not possible to get this GameSingleton in the component constructor, which results in poor architecture and the need for runtime calls.
- Static variable. There are just my guesses and that would be a solution, but UProperty does not support static variables. But I need to set blueprint class from editor.
That’s all that came to my mind the whole time. Guys, I would be glad if you could help me with this problem and I would like to solve it in the best possible way from an architectural point of view. Any help is welcome and thanks in advance.