diff --git a/CHANGELOG.md b/CHANGELOG.md index 17fce49b94..f514f748b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Fixed an `IndexOutOfRangeException` that could be thrown when editing your 'Build Configuration' asset. [#1441](https://github.com/spatialos/gdk-for-unity/pull/1441) - The 'Build Configuration' Inspector window will no longer report your Android SDK installation as missing if you have a completely fresh Unity installation with the bundled Android SDK. [#1441](https://github.com/spatialos/gdk-for-unity/pull/1441) - Fixed a bug where having spaces in the path to your project would cause the 'Local launch' and 'Launch standalone client' menu options to fail on MacOS. [#1442](https://github.com/spatialos/gdk-for-unity/pull/1442) +- Fixed a faulty sync point caused by using `ComponentDataFromEntity` of the `WorkerSystem`. [#1430](https://github.com/spatialos/gdk-for-unity/pull/1430) ### Internal diff --git a/workers/unity/Packages/io.improbable.gdk.core/.codegen/Source/Generators/Core/UnityEcsViewManagerGenerator.cs b/workers/unity/Packages/io.improbable.gdk.core/.codegen/Source/Generators/Core/UnityEcsViewManagerGenerator.cs index eb3678f356..981842e57c 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/.codegen/Source/Generators/Core/UnityEcsViewManagerGenerator.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/.codegen/Source/Generators/Core/UnityEcsViewManagerGenerator.cs @@ -33,6 +33,7 @@ public static CodeWriter Generate(UnityComponentDetails componentDetails) { evm.Line($@" private WorkerSystem workerSystem; +private SpatialOSReceiveSystem spatialOSReceiveSystem; private EntityManager entityManager; private readonly ComponentType[] initialComponents = new ComponentType[] @@ -63,7 +64,7 @@ public void ApplyDiff(ViewDiff diff) } var updates = diffStorage.GetUpdates(); - var dataFromEntity = workerSystem.GetComponentDataFromEntity(); + var dataFromEntity = spatialOSReceiveSystem.GetComponentDataFromEntity(); for (int i = 0; i < updates.Count; ++i) { ApplyUpdate(in updates[i], dataFromEntity); @@ -92,6 +93,13 @@ public void Init(World world) { throw new ArgumentException(""World instance is not running a valid SpatialOS worker""); } + + spatialOSReceiveSystem = world.GetExistingSystem(); + + if (spatialOSReceiveSystem == null) + { + throw new ArgumentException(""Could not find SpatialOS Receive System in the current world instance""); + } } "); evm.Method("public void Clean()", m =>