I want to make a component that has a Viewport so I can place various elements in it (UI elements that will be on top of enemies in my game).
As I don’t want to have to add those UI elements to all my actor classes, I would like to make a component that can contain all those things neatly packaged and be simply added to any actor I want.
- There is the
SceneComponentclass which _does _ have a transform, but it doesn’t have a viewport, meaning it’s not very usable as I would need to place/instantiate everything in code/blueprints. I want to place things visually in the viewport
- I could use the
ChildActorComponent, but it requires casting, and I don’t really like the idea of having to make my UI an actual actor
Is there any other component class I could use that can be attached to an actor’s transform and has a viewport where I can edit its content?
More detailed explanation of the problem
For clarity, by Viewport I mean the Viewport that you would have in an Actor, where you can place elements inside that specific actor. This window is only available when editing an actor, not when editing a scene component, so it’s impossible to create a scene component that has a visual editor to place things inside.
Here are some screenshots to illustrate what I mean:
This is my main unit blueprint. As you can see it contains a “UnitUI” child actor, which contains all the UI features for units. I could only make it as a child actor, because a
SceneComponent doesn’t have a viewport to place elements.
This is the content of my UnitUI actor:
In this example it only has one element inside, but eventually there will be multiple different UI elements all placed in the viewport. I don’t want to have to add those elements manually to all my unit blueprints, so I made this
UnitUI actor to contain and control all of them, while the main
Unit actor will only code simple functions from the
Scene components don’t have any viewport, here’s a screenshot from a scene component, with no viewport option:
This means that using a scene component, I would be unable to place my UI elements visually in the viewport, and they would have to be instantiated/placed in code, which isn’t a good workflow.