x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to Load Array of Struct with Config

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.

Product Version: UE 4.18
Tags:
more ▼

asked Mar 21 '18 at 11:32 PM in C++ Programming

avatar image

lufthansa747
3 1 3 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question