Download

[Resolved] How update UProperty value in derived class?

How i can update displayName UProperty value in child class (UuazVehicle_C) to “uaz”?
Tried this (no work. UuazVehicle_C class have parent displayName UProperty value - “baseCar”):



UCLASS(Blueprintable)
class Ubase_car_C : public UAll_C { //derived from UObject
     GENERATED_BODY()

     UPROPERTY(EditAnywhere,BlueprintReadWrite) FString displayName;

     public: Ubase_car_C() {
          displayName = "baseCar";
          UE_LOG(LogTemp, Warning, TEXT("constructor Ubase_car_C"));
     };
};
UCLASS(Blueprintable)
class UuazVehicle_C : public Ubase_car_C {
     GENERATED_BODY()

     FString displayName; //problem here, need just delete this string...

     public: UuazVehicle_C() {
          displayName = "uaz";
          UE_LOG(LogTemp, Warning, TEXT("constructor UuazVehicle_C"));
     };
};



P.S.


UE_LOG(LogTemp, Warning, TEXT("displayName:%s"), *this->displayName);

in UuazVehicle_C constructor - show in log displayName:uaz

You declared displayName twice. You have it in the base class, and the child class as well. Aren’t you getting errors/warnings about this?

No, I will get an error, if I repeat UPROPERTY macros near displayName in subclass (shadow error), can i update\reSet displayName property value in subclass?
w\o UPROPERTY all fine, but i don’t can get this variable and value: my try, get metod:


 FStrProperty* haveKey = FindFProperty <FStrProperty >(MyObj->GetClass(), key);//key == displayName,myObj == created object with
uazVehicle_C type
if (haveKey) {
gettedDataTemp = haveKey->GetPropertyValue_InContainer(MyObj);

problem resolved:
my error:
re-declaration of a class member in the body of the derived class (after this action - dont’ can update property value, property have parent(base) value)