UChildActorComponent of Type

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.

You can use ‘AllowedClasses’ UPROPERTY meta argument to filter classes visible in the editor

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Brush, meta=( AllowedClasses="Texture2D,MaterialInterface" ))
	UObject* ResourceObject;

Can I use this on a UChildActorComponent though. To force the child actor selection to only a specific class type? I tried and couldn’t get it working. Should I maybe use a custom component?

It seems you have to create a copy of UChildActorComponent, but bounded to your preferred class type here:

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=ChildActorComponent, meta=(OnlyPlaceable, AllowPrivateAccess="true"))
	TSubclassOf<AInGameMenu>	ChildActorClass;

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

But why do you need ingame menu to be an actor?

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)