Declaring archetypes in c++

I’m working with an asset that inherits from UObject. This asset is normally created via a custom factory in the editor.

I know that creates a package, instantiates the class (probably with flags RF_Public and/or RF_ArchetypeObject), and then serializes the package into the uasset. These instances then show up as options for properties on my blueprints in the editor.

I would like to declare a bunch of archetypes in c++ and be able to see it in the editor as a choice for properties on my other objects.

I know that I can create my own factory to generate a package with all the assets I would like to declare in code, but this is not quite the same as declaring them in the code.

Does a code module end up being a package in any way?
Can I get a reference to the package in StartupModule()?
Is there some way to call NewObject() in StartupModule(or some other way) such that these instances are visible in the editor?

Here goes the bump hoping this catches the eye of one of the more senior devs.

Hi, I apologize if I misunderstood.

But couldn’t you just create a base-class (such as UMyBase), then have all your objects derive from that class (eg: UMyAsset1 : public UMyBase).
That way you can simply have a UPROPERTY that is a TSubClassOf<UMyBase>
This will allow you to select any of the derived classes, or blueprints made from them?

Thanks for responding. That is a pretty useful technique that I like to use a lot. It does come with the overhead of adding a bunch of classes to the project though. you also have to work with your CDO in that scenario a lot of times.

Maybe someone can point me in the right direction to better understand how modules and packages interact?

It’s certainly possible to create assets from code. I think the editor dropdowns use the asset registry, so after calling NewObject you would want to get a reference to IAssetRegistry to notify it of the new asset.
Is your intention that these would be visible in dropdowns, but not visible in the content browser? Whether or not that’s possible I’m not sure.