Unitys Prefab Equivalent in Unreal or similar or how do I make some specific kind of object?

Hi guys,

I’m coming from Unity to Unreal Engine. I think I’ve understood most of the core concepts of unreal and already programmed for some months.

One feature that I’m missing (or did not find till now) is kind of a prefab. I mean an asset which is can be dragged into the scene and can be used afterward.

Let me explain alongside a small example.
I have an actor blueprint that contains some widgets and some other visuals. Lets call it UiContainer
Since I am in VR I’m not using the standard buttons, instead, I want to implement them myself.
I already did and they work quite well.
I made an actor blueprint for the buttons with the logic inside that blueprint (with button pressed event etc.).

Atm I have to place the UiContainer into the level, and then drag the buttons into the level, make them children of the UiContainer, and put them into the right position. In the UiContainer I have references to them for listening to the button events.

The problem is, that I (or a game designer or anyone else) have to redo the procedure in another level.
Dragging the UiContainer, the buttons, doing the parenting, and passing the references.
In Unity I could simply make a prefab with these components and keep the logic on the objects themself (e.g.button logic on buttons).

In Unreal I cannot add an actor blueprint to another actor blueprint. I cannot save the construct as a whole but have to save the components instead. As for my understanding that scales not well.

And putting the logic only inside the UiContainer is also not an option. The buttons, for example, could be also used for other use cases in other objects. When I want to change the button logic I would have to change each button bp respectively. I want to change one button (visuals or logic) and then the changes should propagate through all instances of the buttons.

I think I’m missing some key concepts of actor and components. Afaik actor bps contain logic and subcomponents.
These components can be Actor Component which contains logic but is not bound to a visual representation or Scene Components which do have a scene transform and can contain meshes and therefore a visual representation. However they lack logic…

As said I think I’m missing some keyconcepts in UE and I hope one of you can help me :slight_smile:

Actually is quite simple.

The Actor can have Child Actor Components. So you can package together a complex Actor with different stuff in it that an be then dragged to the scene.

I always direct users to check this amazing free resource created by unreal, use Open Level File Menu option to browse trough a lot of examples

I think the closest equivalent to Prefab in Unreal is the Blueprint Class itself, no?

You can packages inside a Blueprint Class multiple components and instanciate this class on your level.

If I understood your question, you want to make your button do things that are not in the original Blueprint but rather on the instance of it ? If so, I think your button should fire an Event Dispatcher… to witch you attach your code to when you create an instance of the blueprint.

This way, I’m not hardcoding what the button do in the blueprint? Much like you would do when you add a listener to OnClick ?

Hope I got this right,
Cheers

Yeah you are right but im missing visual finetuning in your solution. When I have different versions with different button positions I have to set them by code I think. Therefore, this would be tedius for repeated usage.

The solution with the child actors fits better I think. However, the naming in the editor is quite ambiguous.
image
Like this for example. I cannot click on them as I will always automatically select the TaskManager. I can click on them in the details view but renaming is not an option I can see. However, this is only a minor annoyance and I can live with that.

you can create a master blueprint with all the stuff in it, then create a child blueprint (in the content panel) maybe this is what your try to do?

Nah, not exactly. It isn’t the logic alone. Furthermore I want to see and alter the visuals like the button placement (which are also actors).

As I’ve alread said, your solution with child actors works nicely for now. The only thing left is the improper naming and that the public variables of the child actor are not accessible in the editor.

Here’s a link to another post that states that this feature is missing and will most likely be never resolved.

https://forums.unrealengine.com/t/how-to-access-exposed-variables-of-a-child-actor-component-via-the-details-panel/327959/13

In my view this makes implementing modular actors much harder and time consuming.

I remember having this issue now as well. A solution that appeared to work, but I never tried, is to use C++ and create your own custom component, instead of having the child component load the blueprint.

I’ve made a tool for creating prefab like blueprints: