Skip to content

Commit

Permalink
fix(UnityIntegration): prevent serialization issues
Browse files Browse the repository at this point in the history
If a Unity project wasn't yet using Malimbe and runs it for the
first time during the startup of the Unity editor Unity won't pick
up changes of serialized values correctly until the serialized asset
was touched at least once. The fix is to revert the integration
behavior so it runs the weaving process on startup. This brings back
an old issue: The Unity console will be logging issues regarding
"Unity extensions" hundreds of times. To prevent this the Unity API
that logs those errors is no longer called instead. No behavioral
change has been observed and as such this change is not labeled a
breaking change.
  • Loading branch information
Christopher - Marcel Böddecker committed Feb 13, 2019
1 parent 9ef91c3 commit 3ef85e2
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions Sources/FodyRunner.UnityIntegration/EditorWeaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,8 @@ internal static class EditorWeaver
[InitializeOnLoadMethod]
private static void OnEditorInitialization()
{
void OnDelayCall()
{
// ReSharper disable once DelegateSubtraction
EditorApplication.delayCall -= OnDelayCall;

CompilationPipeline.assemblyCompilationFinished += OnCompilationFinished;
WeaveAllAssemblies();
}

EditorApplication.delayCall += OnDelayCall;
CompilationPipeline.assemblyCompilationFinished += OnCompilationFinished;
WeaveAllAssemblies();
}

[MenuItem("Tools/" + nameof(Malimbe) + "/Weave All Assemblies")]
Expand Down Expand Up @@ -103,8 +95,7 @@ private static void OnCompilationFinished(string path, CompilerMessage[] message

[NotNull]
private static IEnumerable<Assembly> GetAllAssemblies() =>
CompilationPipeline.GetAssemblies(AssembliesType.Player)
.Concat(CompilationPipeline.GetAssemblies(AssembliesType.Editor))
CompilationPipeline.GetAssemblies(AssembliesType.Editor)
.GroupBy(assembly => assembly.outputPath)
.Select(grouping => grouping.First());

Expand Down

0 comments on commit 3ef85e2

Please sign in to comment.