I am trying to use the Config system to allow me to load an array from a Default.ini file.
UENUM()
enum SensorType { RADAR = 0, LIDAR };
UCLASS(config = Game)
class USensorPlacementConfigData : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(Config, BlueprintReadWrite, EditAnywhere)
float rot_x;
UPROPERTY(Config, BlueprintReadWrite, EditAnywhere)
float rot_y;
UPROPERTY(Config, BlueprintReadWrite, EditAnywhere)
float rot_z;
UPROPERTY(Config, BlueprintReadWrite, EditAnywhere)
float rot_w;
UPROPERTY(Config, BlueprintReadWrite, EditAnywhere)
float scale_x;
UPROPERTY(Config, BlueprintReadWrite, EditAnywhere)
float scale_y;
UPROPERTY(Config, BlueprintReadWrite, EditAnywhere)
float scale_z;
UPROPERTY(Config, BlueprintReadWrite, EditAnywhere)
float trans_x;
UPROPERTY(Config, BlueprintReadWrite, EditAnywhere)
float trans_y;
UPROPERTY(Config, BlueprintReadWrite, EditAnywhere)
float trans_z;
UPROPERTY(Config, BlueprintReadWrite, EditAnywhere)
TEnumAsByte<SensorType> type;
};
UCLASS(Config = Game)
class WATOSIM_API ASensorMountedVehicle : public AWheeledVehicle
{
GENERATED_BODY()
public:
UPROPERTY(Config, BlueprintReadWrite, EditAnywhere)
TArray<TSubclassOf<class USensorPlacementConfigData >> sensors;
//UPROPERTY(BlueprintReadWrite, EditAnywhere)
TArray<class ASceneCapture2D *> mountedSensors;
//UPROPERTY(BlueprintReadWrite, EditAnywhere)
TArray<class UTextureRenderTarget2D *> sensorRenderTargets;
public:
virtual void BeginPlay() override;
virtual void Tick(float DeltaTime) override;
~ASensorMountedVehicle();
};
I am trying to load the sensor arrya with the following .ini
[Script/WATOSIM_API.SensorPlacementConfigData]
rot_x=0, /
rot_y=0, /
rot_z=0, /
rot_w=0, /
scale_x=0, /
scale_y=0, /
scale_z=0, /
trans_x=0, /
trans_y=0, /
trans_z=100, /
type=USensorPlacementConfigData::SensorType::LIDAR
The code to load the array is
void ASensorMountedVehicle::BeginPlay()
{
Super::BeginPlay();
UE_LOG(LogTemp, Error, TEXT("NumSensor: %d"), sensors.Num());
sensorRenderTargets.Reset();
for (auto &sensor : sensors) {
auto s = sensor.GetDefaultObject();
UE_LOG(LogTemp, Error, TEXT("%f %f %f %f, %f %f %f, %f %f %f, %d"),
s->rot_x, s->rot_y, s->rot_z, s->rot_w, s->scale_x, s->scale_y, s->scale_z,
s->trans_x, s->trans_y, s->trans_z, (int)s->type.GetValue()
);
}
In the editor I am able to set the arrays default value, I added one element, but have no option to edit the actual values for each struct.