Description

Preforming a hot reload causes placed actors to lose code based variable settings.

More repro steps:
1. Open UE4Editor.exe
2. Create a First Person Code project
3. Build the project for Development Editor Win64 in Visual Studio
4. Open UE4Editor.exe
5. Open the built First Person Code project
6. Select File > New C++ class > Actor > Next
7. Select Create Class to create a new class based on Actor called MyActor
8. Select File > New C++ class > Show All Classes
9. Search for MyActor and select it
10. Select Next > Create Class to create a new class based on MyActor called MyMyActor
11. Add the following code to the public section of MyActor.h (line 26)

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = test)
	AMyActor* MyActorPtr;
	
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = test)
	float RandomNum;

12. Close UE4Editor.exe
13. Build MyProject for Development Editor Win64 in Visual Studio
14. Open the First Person Code project back up into UE4Editor while leaving Visual Studio open
15. Select View Options > Show C++ Classes in the content browser
16. Locate the MyActor and MyMyActor classes in the content browser
17. Drag the MyActor and MyMyActor classes from the content browser into the viewport
18. Select MyActor from Scene Outliner (MyActor1)
19. Set MyActorPtr to MyMyActor1 and RandomNum to 5
20. Switch back to Visual Studio and open MyActor.h
21. Rename RandomNum to RandomNum2
22. Compile the template project for Development Editor Win64 in Visual Studio
23. Switch back to UE4Editor and select MyActor1 in the World Outliner
24. Locate the MyActorPtr and RandomNum2 properties in the Details panel for MyActor1

RESULT:
MyActorPtr is set to None

Expected
The MyActorPtr of MyActor1 is still set to MyMyActor1 after hot reloading

Steps to Reproduce
  1. Open UE4 Editor (any project)
  2. Add code to project based on Actor (MyActor)
  3. Add another code class based on MyActor (MyChildActor)
  4. Add the following to MyActor.h:
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = test)
    	AMyActor* MyActorPtr;
    	
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = test)
    	float RandomNum;
    
  5. Compile
  6. Add instance of MyActor and MyChildActor to the viewport
  7. Select MyActor from Scene Outliner (MyActor1)
  8. Set MyActorPtr to MyChildActor (MyChildActor1) and RandomNum to any non-zero value
  9. In Visual Studio, change RandomNum to RandomNum2
  10. Compile to hot reload

Result:
MyActorPtr for MyActor1 is reset to none and RandomNum2 is reset to zero after the hot reload.

Expected:
The variable values remains after the hot reload.

Have Comments or More Details?

Head over to the existing Questions & Answers thread and let us know what's up.

345
Login to Vote

Fixed
ComponentUE - Foundation - Cpp Tools - Hot Reload
Affects Versions4.17.24.184.194.23
Target Fix4.26
Fix Commit13762913
Main Commit14207746
CreatedNov 9, 2017
ResolvedJun 24, 2020
UpdatedSep 6, 2020
Pull Requests
5830 - Algorithman