Search Issue Tracker
Third Party Issue
Votes
15
Found in
2020.2.0b3
2020.3
2020.3.13f1
2021.1
Issue ID
1350116
Regression
Yes
Unity does not execute code weavers when the project is opened for the first time
How to reproduce:
1. Download user attached project "unity2020-weaver-bug.zip"
2. Inside the project folder, delete the "Library" folder
3. Open the project
4. Enter Scene "SampleScene"
5. In the Hierarchy window, click on a Game Object "GameObject"
6. In the Inspector window, observe the "Tester" Component
Expected result: Both "Basic" and "TestNum" fields are shown
Actual result: Only the "Basic" field is shown
Reproducible with: 2020.2.0b3 2020.3.13f1, 2020.3.15f2, 2021.1.16f1
Not reproducible with: 2019.4.29f1, 2020.2.0b2
Can't test: 2021.2.0b6, 2022.1.0a5 (Console error: "An infinite import loop has been detected. The following Assets were imported multiple times, but no changes to them have been detected. Please check if any custom code is trying to import them")
Note:
-By invoking ReloadAssemblies (by reopening a project, modifying a script) the "TestNum" field appears
-If we do a build of the project, the built application will crash upon launching
-If we do a build after reopening the project, the built will not crash
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [Linux] "Trying to load color backbuffer into a complex RenderPass setup" error is thrown after entering Play mode in AR Mobile template project
- [Android] Neither of the callbacks are called when several videos with VideoPlayer are spawned on the target on the Google Pixel devices
- Texture2D memory allocation size is significantly increased when running on iOS device
- No data received in Profiler when connecting to WebGL Player without "Autoconnect Profiler" option enabled
- Screen Space Ambient Occlusion is ignored when toggling "Post Processing" visibility in the Scene window overlay
Resolution Note (2022.1.X):
The issue has been confirmed to come from https://github.com/ExtendRealityLtd/Malimbe/blob/98b63aac53fbf1358643b7f5137d677ada95bcd4/Sources/FodyRunner.UnityIntegration/EditorWeaver.cs#L53:
Explanation here:
- When loading a project containing user code, we have 2 domain reloads: the inital one that loads unity own assembly, compile the code and trigger the second reload that contains compiled scripts
- Before 2020.3 we used to load pre-compiled assemblies during the first domain reload: thus the second domain reload happened after foddy integration initialization, picking up the changes it injected.
- Starting with 2020.3, the ordering did change a little bit, to prevent issues where pre-compiled assemblies can depend on script code to execute correctly
- AssetDatabase does not track assemblies from script compilation, only the source files, but the changes produced by foddy only modify the compiled assemblies.
- Now that the initialization occur on the 2nd reload, there is no other change, or other system triggering a domain reload picking up the changes brought by Foddy: the assemblies are weaved, but not reloaded.
To fix that, instead of triggering an ADB refresh, Foddy integration package should trigger a domain reload using https://docs.unity3d.com/ScriptReference/EditorUtility.RequestScriptReload.html.
We opened a PR to help fixing the issue here: https://github.com/ExtendRealityLtd/Malimbe/pull/69