Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 03f85ef

Browse files
authored
Upgrade to entities 0.14.0-preview.18 (#1463)
* Upgrade to entities 0.14.0-preview.18 * Fix android * Fix TransformSync using deprecated EntityManager null * Changelog and Upgrade guide * Fix codegen using deprecated methods * Remove unused usings
1 parent 5098cb6 commit 03f85ef

File tree

12 files changed

+30
-50
lines changed

12 files changed

+30
-50
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
### Breaking Changes
66

77
- The minimum supported version of Unity is now 2020.1. [#1459](https://github.com/spatialos/gdk-for-unity/pull/1459)
8+
- Upgraded Unity Entities to 0.14.0-preview.18. [#1463](https://github.com/spatialos/gdk-for-unity/pull/1463)
9+
- Projects now require the `Unity Web Request` built-in package to compile for iOS and Android.
810

911
### Added
1012

UPGRADE_GUIDE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
In order to use the GDK for Unity `0.4.0`, you will need to upgrade your project to Unity 2020.1. We test against 2020.1.2f1, but any `2020.1.x` version _should_ work.
88

9+
### Unity Entities 0.14
10+
11+
Due to our internal upgrade to Unity Entities `0.14.0-preview.18`, your projects are now required to include the `Unity Web Request` built-in package.
12+
You can find this package in the Unity editor under the `Window -> Package Manager` menu.
13+
914
## From `0.3.9` to `0.3.10`
1015

1116
### AuthorityLossImminent support removed

workers/unity/Assets/Tests/PlaymodeTests/Correctness/TransformSynchronization/TransformInitialisationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public IEnumerator Transform_initialises_on_enable_and_resets_on_disable()
6262
RequireLifecycleSystem.Update();
6363

6464
Assert.IsFalse(transformSyncBehaviour.enabled);
65-
Assert.IsNull(GetPrivateField<EntityManager>(transformSyncBehaviour, "entityManager"));
65+
Assert.AreEqual(GetPrivateField<EntityManager>(transformSyncBehaviour, "entityManager"), default(EntityManager));
6666
Assert.IsFalse(GetPrivateField<bool>(transformSyncBehaviour, "initialised"));
6767
}
6868

workers/unity/Packages/io.improbable.gdk.core/.codegen/Source/Generators/Core/UnityEcsViewManagerGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public void Init(World world)
173173
{
174174
m.Line(@"
175175
var entity = workerSystem.GetEntity(update.EntityId);
176-
if (!dataFromEntity.Exists(entity))
176+
if (!dataFromEntity.HasComponent(entity))
177177
{
178178
return;
179179
}

workers/unity/Packages/io.improbable.gdk.core/Utility/PlayerLoopUtils.cs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Reflection;
54
using Unity.Entities;
65
using UnityEngine;
7-
using UnityEngine.LowLevel;
86

97
namespace Improbable.Gdk.Core
108
{
@@ -72,38 +70,9 @@ public static void ResolveSystemGroups(World world)
7270
type == typeof(PresentationSystemGroup))
7371
{
7472
var groupSystem = system as ComponentSystemGroup;
75-
groupSystem.SortSystemUpdateList();
73+
groupSystem.SortSystems();
7674
}
7775
}
7876
}
79-
80-
public static void RemoveFromPlayerLoop(World world)
81-
{
82-
var playerLoop = PlayerLoop.GetCurrentPlayerLoop();
83-
84-
//Reflection to get world from PlayerLoopSystem
85-
var wrapperType =
86-
typeof(ScriptBehaviourUpdateOrder).Assembly.GetType(
87-
"Unity.Entities.ScriptBehaviourUpdateOrder+DummyDelegateWrapper");
88-
var systemField = wrapperType.GetField("m_System", BindingFlags.NonPublic | BindingFlags.Instance);
89-
90-
for (var i = 0; i < playerLoop.subSystemList.Length; ++i)
91-
{
92-
ref var playerLoopSubSystem = ref playerLoop.subSystemList[i];
93-
playerLoopSubSystem.subSystemList = playerLoopSubSystem.subSystemList.Where(s =>
94-
{
95-
if (s.updateDelegate != null && s.updateDelegate.Target.GetType() == wrapperType)
96-
{
97-
var targetSystem = systemField.GetValue(s.updateDelegate.Target) as ComponentSystemBase;
98-
return targetSystem.World != world;
99-
}
100-
101-
return true;
102-
}).ToArray();
103-
}
104-
105-
// Update PlayerLoop
106-
ScriptBehaviourUpdateOrder.SetPlayerLoop(playerLoop);
107-
}
10877
}
10978
}

workers/unity/Packages/io.improbable.gdk.core/Worker/WorkerConnector.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.IO;
5-
using System.Linq;
65
using System.Text.RegularExpressions;
76
using System.Threading;
87
using System.Threading.Tasks;
98
using Improbable.Worker.CInterop;
10-
using Improbable.Worker.CInterop.Alpha;
119
using Unity.Entities;
12-
using UnityEditor;
1310
using UnityEngine;
14-
using UnityEngine.LowLevel;
1511

1612
namespace Improbable.Gdk.Core
1713
{
@@ -105,7 +101,7 @@ protected async Task Connect(IConnectionHandlerBuilder builder, ILogDispatcher l
105101

106102
// Update PlayerLoop
107103
PlayerLoopUtils.ResolveSystemGroups(Worker.World);
108-
ScriptBehaviourUpdateOrder.UpdatePlayerLoop(Worker.World, PlayerLoop.GetCurrentPlayerLoop());
104+
ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(Worker.World);
109105
}
110106
catch (Exception)
111107
{
@@ -251,7 +247,7 @@ private void RemoveFromPlayerLoop()
251247
{
252248
// Remove root systems from the disposing world from the PlayerLoop
253249
// This only affects the loop next frame
254-
PlayerLoopUtils.RemoveFromPlayerLoop(Worker.World);
250+
ScriptBehaviourUpdateOrder.RemoveWorldFromCurrentPlayerLoop(Worker.World);
255251
}
256252
}
257253

workers/unity/Packages/io.improbable.gdk.core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"io.improbable.worker.sdk": "0.3.10",
1010
"io.improbable.gdk.tools": "0.3.10",
1111
"io.improbable.gdk.testutils": "0.3.10",
12-
"com.unity.entities": "0.9.1-preview.15"
12+
"com.unity.entities": "0.14.0-preview.18"
1313
}
14-
}
14+
}

workers/unity/Packages/io.improbable.gdk.debug/WorkerInspector/EntityListData.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ public void SetNewWorld(World newWorld)
4141
{
4242
fullData.Clear();
4343
FilteredData.Clear();
44-
query?.Dispose();
44+
45+
if (query != default)
46+
{
47+
query.Dispose();
48+
}
4549

4650
if (newWorld == null)
4751
{
4852
world = null;
49-
query = null;
53+
query = default;
5054
return;
5155
}
5256

@@ -65,10 +69,10 @@ public void RefreshData()
6569
using (refreshDataMarker.Auto())
6670
{
6771
fullData.Clear();
68-
var spatialOSComponentType = world.EntityManager.GetArchetypeChunkComponentType<SpatialEntityId>(true);
72+
var spatialOSComponentType = world.EntityManager.GetComponentTypeHandle<SpatialEntityId>(true);
6973
var metadataComponentType =
70-
world.EntityManager.GetArchetypeChunkComponentType<Metadata.Component>(true);
71-
var ecsEntityType = world.EntityManager.GetArchetypeChunkEntityType();
74+
world.EntityManager.GetComponentTypeHandle<Metadata.Component>(true);
75+
var ecsEntityType = world.EntityManager.GetEntityTypeHandle();
7276

7377
using (var chunks = query.CreateArchetypeChunkArray(Allocator.TempJob))
7478
{

workers/unity/Packages/io.improbable.gdk.playerlifecycle/Systems/PlayerHeartbeat/HandlePlayerHeartbeatResponseSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected override void OnUpdate()
4444
{
4545
ref readonly var response = ref responses[i];
4646
var spatialId = response.EntityId;
47-
if (!workerSystem.TryGetEntity(spatialId, out var entity) || !heartbeats.Exists(entity))
47+
if (!workerSystem.TryGetEntity(spatialId, out var entity) || !heartbeats.HasComponent(entity))
4848
{
4949
continue;
5050
}

workers/unity/Packages/io.improbable.gdk.transformsynchronization/MonoBehaviours/TransformSynchronization.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private void OnDisable()
7979
StopAllCoroutines();
8080
RemoveStrategies();
8181

82-
entityManager = null;
82+
entityManager = default;
8383
workerType = null;
8484
initialised = false;
8585
}

0 commit comments

Comments
 (0)