I'm lazy. Why can't I do this?

I have a debug build of my app and a shipping build. During debug & development, I want to use one particular default path. In the deployed version of my app, I want to use a different default path. I am too lazy to go back and change my defaults every time I switch between debug and shipping (and I want to avoid forgetting and human error), so I decided it would be a good idea to wrap it in a pre-processor. However, the UE4 build tool doesn’t like it when I put UPROPERTY inside of a pre-processor. I tried to be clever by moving it outside, but it doesn’t work. Am I relegated to commenting and uncommenting every time I switch between builds?!



UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Settings")
#if !UE_BUILD_SHIPPING
        FString DataDir =  TEXT("C:\\Imagery_data\\");
#else
        FString DataDir = TEXT("Y:\\"); 
#endif


Try assigning the variable in one of your initial c++ functions. Should work fine there



UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Settings") FString DataDir


c++



somefunction(){
#if !UE_BUILD_SHIPPING
DataDir =  TEXT("C:\\Imagery_data\\");
#else        
DataDir = TEXT("Y:\\");  
#endif
} 

I’m guessing it doesn’t like what you did because you could not-declare the variable in one of the pre-processors which causes problems. However in the c++ file it doesn’t matter if something is left out or not.