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{
GENERATED_BODY()
class TestClass2{
public:
int32 testINT;
};
class TestClass1{
public:
int32 aNumberThing;
TArray<TestClass2> otherClassThing;
};
public:
UComponentTest();
UPROPERTY(EditAnywhere)
TestClass1 testThingy;
protected:
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?