I’m trying to use UE for quick prototyping with a mixed approach of both C++ and Blueprints, so that means creating Actors and Components constantly, moving and changing them around all the time.
Making C++ changes and then compiling them with Live Coding or Hot Reload causes constant Blueprint corruption and UE crashes.
Even with small changes such as adding new components to an Actor, renaming components or changing properties of UFUNCTIONs.
I’m not talking here about extensive components, even a bare bones component/Actor causes this.
Both Live Coding and Hot Reload causes the problem in different ways, but the end result is always corruption and/or crashes.
Update - Solved:
UE Versions
I was having the issue with Hot Reload in UE4.7
Then I migrated the project to UE 5.0.1 and the issues got even worse with Live Coding, plus UE 5.0.1 crashes even more with what I am going to describe.
Windows 10, using Rider
Example
Considering a very simple component:
class GAME_API USomeComponent: public USceneComponent
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
UArrowComponent* ArrowComponent;
//...
ArrowComponent = CreateDefaultSubobject<UArrowComponent>(TEXT("ArrowComponent"));
ArrowComponent->AttachToComponent(this, FAttachmentTransformRules::KeepRelativeTransform);
Then you create a Blueprint that inherits from ASomeCharacer and create some Blueprint code using the ArrowComponent and you also make changes to the ArrowComponent component in the viewport, for example, you move it around.
Updating the code and then breaking everything
Now, add a new UPROPERTY to USomeComponent and also a new UFUNCTION, tiny changes.
If I use Live Coding, the Details Panel of both USomeComponent and USomeComponent.ArrowComponent in the Viewport gets blank (blank as in an empty Canvas Panel slate, no properties or fields are displayed anymore) and all the previous references used in Blueprint get errored and I have to create the Blueprint code from scratch.
If I use Hot Reload, the Viewport changes of USomeComponent and USomeComponent.ArrowComponentget reset and the Blueprint references also get errored.
Then if I delete the references in Blueprint code and then rewrite the Blueprint code, as soon as I try to get a reference to USomeComponent, let’s say by using a default Blueprint Get Some Component, UE crashes.
Corrupting the whole project with a Component rename
Things get even worse if I change the code ArrowComponent = CreateDefaultSubobject<UArrowComponent>(TEXT("ArrowComponent")); to for example ArrowComponent = CreateDefaultSubobject<UArrowComponent>(TEXT("NEW NAME")); (Just a component rename), and then Live Reload (UE5).
Then I can’t even reopen my project anymore because it keeps crashing on restart.
I use Git, of course, but recovering Blueprints from Git make them incompatible with the C++ changes, thus the end result is the same: corrupted work.
Solution
Is closing UE, re-building the solution and re-opening the Editor for every header change the way to avoid this?
Are Live Coding and Hot Reload only suitable for implementation changes?
Is there anything I have to tweak to reduce the amount of corruption and crashes?
For quick prototyping is it more suitable to use only Blueprints? (not because of the code itself in my case, but because of the Live Coding issues. If I have to close/reopen the Editor all the time, it goes against the idea of “quick prototyping”).
Ok, thanks. That’s really unfortunate, not really suited for prototyping then. Yesterday for example I counted roughly 120 crashes/corruptions/etc. I can write code quite fast, but then my idea of prototyping is to quickly iterate over constant changes - which is impossible then using C++ with UE (due to this workflow of re-opening the editor all the time or dealing with corruption).
In conclusion, the approach then is to first make a base framework with C++, compile it and then make everything with Blueprints, inheriting from the base framework, without touching the base framework again while doing quick iterations.
But then I need the new features added via C++ to the Components/Actors to extend and use them with Blueprints. And if I live code/hot reload, they get corrupted anyway. So closing and re-opening the editor constantly is a must to keep getting access to the new features I implement with C++
In 4.x, you are mostly correct – you should only use Live Coding when making code changes, not structural changes.
I haven’t used it yet, but I believe 5.x supports reinstancing objects while running, so you can do a Live Coding update, and it will absorb structural changes without destroying things quite so handily.
I don’t have a ton of experience with this myself, but from what I’ve noticed it seems that if you change header files or constructors, live coding is going to get messed up, possibly requiring you to do a FULL CLEAN of intermediate files, regenerate project files and a full rebuild, which is annoyingly slow and wasteful of time.
It seems much safer and more time efficient (e.g. not risking intermediate file corruption) to just close the editor, recompile from Rider and relaunch the editor.
Where hot reload does seem to work great is in runtime-only code, like you want to change how some loop or logic works or whatever. It’s great for iterating the details of what any given function does, but not for iterating the structure itself.
If/when the code structure itself changes, hot reload seems to be more trouble than it’s worth.
I deleted the Jet Brains Rider plugin folders from the Engine/Plugins/Developers folder and re-generated the project using UE (File → Refresh Rider Project).
I added the Jet Brains Rider plugin to the project itself, then refreshed it again.
Then I removed the plugin folders from the project and added to the engine source again.
And now, everything works smoothly with Live Coding (UE5). I haven’t tested Hot Reload with UE4 anymore, but now I’m able to quick iterate code changes without those crashes and corruption.
I use Rider as a game plugin, not as an engine plugin, and mine stays up to date all the time. Every time Rider itself updates, it wants to update its plugin and I allow it to do so.
Live coding still crashes causes asset (blueprint) corruption if you use it “incorrectly.”
Are you saying that with it installed as an engine plugin, you can now make structural C++ changes and those take effect in the editor without corruption?
No, sorry. I should’ve made it more explicit what was really solved:
Live Reload is at least twice as fast after my “fix”.
I don’t have Editor crashes with Live Coding anymore (as opposed to 120 crashes on the day of the report). I think that’s my biggest win.
Blueprints still get corrupted if they are open in the Editor while I refresh the code with CTRL+ALT+F11.
Renaming properties in header files still make me close and re-run the editor, but it’s now quite fast (5 seconds or so), and the Editor doesn’t crash anymore.