Using undo on an assembly reload causes various problems
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 49
Description
Release Type: GitHub or normal release
Version: 4.2.0.2067 and a recent github version
Platform(s): Editor
Describe the bug
You can undo an assembly reload with ctrl+z, and it always causes problems.
I have had:
- Serialization errors requiring restart
- Actual crash of editor
- Adding duplicate copies of scripts that have been changed, other scripts on the same entities, possibly more.
But I did an isolated repro and only saw the first 2
To Reproduce
Steps to reproduce the behavior:
NOTE: It is not necessary for the change to be an error. Making a valid change, and then using undo, will also cause duplicates of scripts.
- Create a new project using the "TopDownRPG" sample.
- Open MainScene in the editor
- Select the first LootBox prefab with the CrateScript component attached. Move this to a different position using the editor.
- Open the code project, and open CrateScript.cs
- Introduce a bug in this class preventing it from compiling.
- Go back to the editor, and reload scripts. It will fail to compile due to the error.
- Go back and remove the typo, making the class the same as it was when the project was first made.
- In the editor, reload script assemblies. This time, it will successfully compile.
- Press ctrl+z repeatedly and watch things break.
Effects of this:
- A second copy of CrateScript is present on the object (the instructions are exact, so the object has been selected the entire time, and you can see this immediately)
- The Trigger script also has a second copy.
- A
System.INvalidOperationException: Cannot convert value to the required typeprevents the scene from rendering - The move is not successfully undone, the object is still in the modified position after undo is pressed many times.
Pressing "Resume" does successfully rescue the editor.
As the reload is undone, you are able to press the "Reload script assemblies" button again. You can press it and get a third copy of the CrateScript and Trigger script on the still
Expected behavior
Personally I don't expect this to be something you can undo, and I never am doing this on purpose!
Additional context
I will submit a PR removing the ability to undo this unless anyone has other ideas to fix 😆
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named. Reproduce the failure in the Stride Editor using the listed TopDownRPG steps, then trace the editor's undo handling around assembly reloads and script recompilation. Done means undo no longer creates duplicate scripts, serialization errors, crashes, or leaves the scene in an incorrect state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100