Hello, I have DataTables with stats for my enemies, weapons, etc.
I’m trying to add UObjects so I can add ***any ***generic additional assets to the enemy: Particles, Meshes, Spawnable Blueprints, Materials, etc. (Which will then be handled in code)
However this never actually shows up inside a DataTable. Any other variable type works just fine, but anything containing a UObject (TMap, TArray, just plain UObject) doesn’t show up.
It works perfectly in other classes and blueprints, but not data tables.
Is there anything additional I need to do to make this work? Or maybe an alternate way to allow any generic asset to be added?
This is because UObject is not a Blueprintable type. If you will look into the source you will notice that it isn’t even an UCLASS or UPROPERTY. When you are using pointers to UObjects you are pointing to the existing, instanced objects.
The thing you should try to do is to have a TSubClassOf<UObject> and then create a new object based on the given subclass.
There is also an “instanced” keyword you can put into a UPROPERTY, which will instance an object when created, but I’m not sure if this will work for this case.
UObject is a blueprintable type, you can create Blueprints and assets that use UObject as a base. UObject is not a common base type for all objects in the content browser though. Blueprints are referenced via TSubclassOf<> because they are classes, while some assets like materials and particles are not subclasses, but are objects in their own right.
IIRC you cannot use ‘Instanced’ in a Data Table because the objects do not end up being properly serialized and do not have a valid outer. If you want to do that, use a DataAsset instead.