Modifying C++ Base Class Resets Derived Blueprint's Variables to Default after Editor Compile

anonymous_user_37eda844
Sun, 19 Nov 2017 23:11:19 +0000
Blueprint

I’m experiencing an issue in 4.18.1 which causes blueprint variables to reset to default values in the editor when the base C++ class’s header file is changed with by adding a comment. The following steps always reproduce the issue:

1. Launch 4.18.1 and create a new C++ 2D Side Scroller project

2. Open the visual studio project from the Unreal Editor if it is not already open. I’m using Visual Studio 2015.

3. Open MyProjectCharacter.h

4. Add a public member variable with a UPROPERTY
UPROPERTY(Category = "Test Variables", EditAnywhere, BlueprintReadOnly)
int m_nTestVar UMETA(DisplayName = "Test Var");

5. Open MyProjectCharacter.cpp

6. Initialize m_nTestVar to 0 in AMyProjectCharacter’s constructor

7. Go to the Unreal editor and compile

8. In the World Outliner tab select TP_2DSideScrollerCharacter

9. In the Details tab, find the Test Variables category and set Test Var to a non-zero number

10. In the editor, File > Save All

11. In MyProjectCharacter.h, add a comment above the m_nTestVar’s UPROPERTY
//A comment
UPROPERTY(Category = "Test Variables", EditAnywhere, BlueprintReadOnly)
int m_nTestVar UMETA(DisplayName = "Test Var");

12. Go to the Unreal editor and compile

13. Test Var is reset to its default value.

If the above steps do not reset the value then follow the next steps:

1. Add a second variable, m_nTestVar2, in MyProjectCharacter.h and initialize it to zero in the constructor as well. The exact same thing as m_nTestVar

2. Go to the Unreal editor and compile.

3. Test Var is reset to its default value.

I’ve tried these step in 4.16.3, and the issue does not exist in that older version. The variables always retain their blueprint value regardless of the number of comments and new variables I add the to base class’s header file.
Is 4.18.1 exhibiting the intended behavior or is this a bug? If this is intended, is there a way to retain the 4.16.3 behavior? 4.18.1 is not usable for me due to this issue.

45 posts - 17 participants