Is it possible to declare a UChildActorComponent as a specific type so the editor is forced to only use an actor of a specific subclass as its child?
//Generic child actor component
UPROPERTY(EditAnywhere, Category = Components)
class UChildActorComponent* MenuComponent;
In the editor the above component can have a child actor of any type associated with it. I want to force the editor to only allow a specific type of actor. In my case it would be AInGameMenu. As a bonus, not having to cast to my specific actor type and check the cast for validity would be a lot cleaner as well.
Other way is writing a property customization class for your actor\component and limit property selections there. It’s not well documented but still possible.
To attach a new customization you need an editor plugin module. There is a lot of code but you can find examples in engine source by this keyword: FOnGetPropertyTypeCustomizationInstance
I’ve not really messed with UChildComponent since 4.8, but it used to be INCREDIBLY buggy due to UChildComponent being FINAL. It actually completely corrupted my uproject file when I added an instance of my class that inherited from UChildComponent. Make sure you backup your project before playing with this class.
I do frequent backups. But I was under the impression you had to use UChildComponent? Even outside of c++ when you drag an actor into another it becomes a child component. I thought you had to use them?
I’m using an Actor because the menu i’m creating needs interaction in the world just like any other object. I could probably do it the proper way but using actors as my buttons was easier. I’m doing this in VR too which always kind of scares you away from using flat overlaid menus. In this case I actually am going flat but that’s just because I think it looks cool and i’m playing around with it.
What I like about UChildActorComponent is that I can instantiate that in c++ and then go over to the editor and select a child actor and then move its location and rotation and stuff right in the editor. So BeginPlay is out of the question because I can’t stand not being able to see design elements without simulate. I haven’t been able to figure out how to use anything else that will spawn the child actor when I choose it from a dropdown list.
Maybe it would nice to use a Widget component to display UI inside the world.
Also you can just copy UChildActorComponent to your project and modify it’s class property as I showed before. (UBT forbides to instanciate a component and modify it’s property)