C++ Class/Struct Issue (Data only)

My end goal is to slap this component on an actor and use the editor to add data using the structure i have in the classes
I need the “+” for the arrays, as they can be any size (will NOT change on runetime, but since theyre created using the editor who knows how many i will add)
and i need multiple data types inside each array. My solution was 2 classes like below

So I right clicked in the UE4 editor and made a new C++ Actor Component. So far so good. I know the process of VS rebuild/UE4 “compile”.

After reading as much as I could, trial and error, I changed the .h file to be like so…

Notes :

** Reading told me that “int” wouldn’t work, and “int32” is what i should be using. I tried both.

** I removed the tick from the .h and .cpp, as well as set bCanEverTick to false in the .cpp. The rest is empty and there is NO functionality. One step at a time

** I tried using a struct instead, but it’s kinda worse

#include “CoreMinimal.h”

#include “Components/ActorComponent.h”

#include “ComponentTest.generated.h”

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class GAMENAME_API UComponentTest : public UActorComponent{

class TestClass2{
		int32 testINT;
class TestClass1{
		int32 aNumberThing;
		TArray<TestClass2> otherClassThing;
	TestClass1 testThingy;
	virtual void BeginPlay() override;


There are NO errors in Visual Studio (Community 2017 with VAX).

UE4 fails to compile with "Error: Unrecognized type ‘TestClass1’ - type must be a UCLASS, USTRUCT, or UENUM
on the “TestClass1 testThingy;” part

If I completely remove the UPROPERTY (making it insible via editor/BP), it compiles successfully, but that’s not what I need.

I’m wanting to have a customizable (instance) that another actor component will be able to read and process.

This C++ class is purely for the data-holding
I want to have like “15” for the aNumberThing, and 3 TestClass2’s in the array (via + button in editor)
but also use the same Actor COmponent to have “22” for the aNumberThing and only 1 TestClass2.

I have the exact same setup in Unity working 100% perfectly. Unity’s inspector correctly shows the “TestClass1 testThingy;” in the inspector and I can input data using the editor
I’m trying to convert this to UE4.

I know I can use like 8 BP “Structures” to achieve this, but that seems messy (my actual implimentation has more TestClass#'s nested inside each other)

Any advice on how I can achieve this?

Or another way to go about it?

UPROPERTY can only be for a USTRUCT and UCLASS

In your case, TestClass1 and TestClass2 are raw classes. You need to turn them into UCLASS (put them in a separate .h/.cpp file and turn it into a UCLASS

UPROPERTY would then be able to reference them

You might want to have a look at UDataAsset. It lets you easily add values from within the editor

class GAMENAME_API TestClass1 : public UDataAsset {

   UPROPERTY(EditAnywhere, Category = "MyData")
   int32 Health;

After you compile this, right click on the content browser, Misc > TestClass1 to create the data asset. Double click this asset to edit your properties

You can then assign these assets to your main class

Using this method, TestClass1 would be converted to a UDataAsset and use UCLASS() as intended, but could i still have a public TestClass2 inside the new UCLASS TestClass1 (and have it shown in the editor)?

I have TestClass1 through TestClass8, all nested inside each other (TestClass1 has TestClass2 plus some variables, TestClass2 has TestClass3 plus some variables, etc). Would I have to make a cpp/h file for ALL 8 classes, converting them to a UCLASS and including them inside each other?

This sounds like a huge pain for something so simple

After testing, it seems like I have to make 8 custom .h/.cpp for the functionality I’m wanting

Is there another way to achieve what I’m trying to do?