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

Commit

Permalink
Upgrade to entities 0.14.0-preview.18 (#1463)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
zeroZshadow authored Aug 26, 2020
1 parent 5098cb6 commit 03f85ef
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 50 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### Breaking Changes

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

### Added

Expand Down
5 changes: 5 additions & 0 deletions UPGRADE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

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.

### Unity Entities 0.14

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.
You can find this package in the Unity editor under the `Window -> Package Manager` menu.

## From `0.3.9` to `0.3.10`

### AuthorityLossImminent support removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public IEnumerator Transform_initialises_on_enable_and_resets_on_disable()
RequireLifecycleSystem.Update();

Assert.IsFalse(transformSyncBehaviour.enabled);
Assert.IsNull(GetPrivateField<EntityManager>(transformSyncBehaviour, "entityManager"));
Assert.AreEqual(GetPrivateField<EntityManager>(transformSyncBehaviour, "entityManager"), default(EntityManager));
Assert.IsFalse(GetPrivateField<bool>(transformSyncBehaviour, "initialised"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void Init(World world)
{
m.Line(@"
var entity = workerSystem.GetEntity(update.EntityId);
if (!dataFromEntity.Exists(entity))
if (!dataFromEntity.HasComponent(entity))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Unity.Entities;
using UnityEngine;
using UnityEngine.LowLevel;

namespace Improbable.Gdk.Core
{
Expand Down Expand Up @@ -72,38 +70,9 @@ public static void ResolveSystemGroups(World world)
type == typeof(PresentationSystemGroup))
{
var groupSystem = system as ComponentSystemGroup;
groupSystem.SortSystemUpdateList();
groupSystem.SortSystems();
}
}
}

public static void RemoveFromPlayerLoop(World world)
{
var playerLoop = PlayerLoop.GetCurrentPlayerLoop();

//Reflection to get world from PlayerLoopSystem
var wrapperType =
typeof(ScriptBehaviourUpdateOrder).Assembly.GetType(
"Unity.Entities.ScriptBehaviourUpdateOrder+DummyDelegateWrapper");
var systemField = wrapperType.GetField("m_System", BindingFlags.NonPublic | BindingFlags.Instance);

for (var i = 0; i < playerLoop.subSystemList.Length; ++i)
{
ref var playerLoopSubSystem = ref playerLoop.subSystemList[i];
playerLoopSubSystem.subSystemList = playerLoopSubSystem.subSystemList.Where(s =>
{
if (s.updateDelegate != null && s.updateDelegate.Target.GetType() == wrapperType)
{
var targetSystem = systemField.GetValue(s.updateDelegate.Target) as ComponentSystemBase;
return targetSystem.World != world;
}

return true;
}).ToArray();
}

// Update PlayerLoop
ScriptBehaviourUpdateOrder.SetPlayerLoop(playerLoop);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Improbable.Worker.CInterop;
using Improbable.Worker.CInterop.Alpha;
using Unity.Entities;
using UnityEditor;
using UnityEngine;
using UnityEngine.LowLevel;

namespace Improbable.Gdk.Core
{
Expand Down Expand Up @@ -105,7 +101,7 @@ protected async Task Connect(IConnectionHandlerBuilder builder, ILogDispatcher l

// Update PlayerLoop
PlayerLoopUtils.ResolveSystemGroups(Worker.World);
ScriptBehaviourUpdateOrder.UpdatePlayerLoop(Worker.World, PlayerLoop.GetCurrentPlayerLoop());
ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(Worker.World);
}
catch (Exception)
{
Expand Down Expand Up @@ -251,7 +247,7 @@ private void RemoveFromPlayerLoop()
{
// Remove root systems from the disposing world from the PlayerLoop
// This only affects the loop next frame
PlayerLoopUtils.RemoveFromPlayerLoop(Worker.World);
ScriptBehaviourUpdateOrder.RemoveWorldFromCurrentPlayerLoop(Worker.World);
}
}

Expand Down
4 changes: 2 additions & 2 deletions workers/unity/Packages/io.improbable.gdk.core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"io.improbable.worker.sdk": "0.3.10",
"io.improbable.gdk.tools": "0.3.10",
"io.improbable.gdk.testutils": "0.3.10",
"com.unity.entities": "0.9.1-preview.15"
"com.unity.entities": "0.14.0-preview.18"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ public void SetNewWorld(World newWorld)
{
fullData.Clear();
FilteredData.Clear();
query?.Dispose();

if (query != default)
{
query.Dispose();
}

if (newWorld == null)
{
world = null;
query = null;
query = default;
return;
}

Expand All @@ -65,10 +69,10 @@ public void RefreshData()
using (refreshDataMarker.Auto())
{
fullData.Clear();
var spatialOSComponentType = world.EntityManager.GetArchetypeChunkComponentType<SpatialEntityId>(true);
var spatialOSComponentType = world.EntityManager.GetComponentTypeHandle<SpatialEntityId>(true);
var metadataComponentType =
world.EntityManager.GetArchetypeChunkComponentType<Metadata.Component>(true);
var ecsEntityType = world.EntityManager.GetArchetypeChunkEntityType();
world.EntityManager.GetComponentTypeHandle<Metadata.Component>(true);
var ecsEntityType = world.EntityManager.GetEntityTypeHandle();

using (var chunks = query.CreateArchetypeChunkArray(Allocator.TempJob))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected override void OnUpdate()
{
ref readonly var response = ref responses[i];
var spatialId = response.EntityId;
if (!workerSystem.TryGetEntity(spatialId, out var entity) || !heartbeats.Exists(entity))
if (!workerSystem.TryGetEntity(spatialId, out var entity) || !heartbeats.HasComponent(entity))
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void OnDisable()
StopAllCoroutines();
RemoveStrategies();

entityManager = null;
entityManager = default;
workerType = null;
initialised = false;
}
Expand Down
3 changes: 2 additions & 1 deletion workers/unity/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0"
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0"
},
"registry": "https://packages.unity.com"
}
3 changes: 3 additions & 0 deletions workers/unity/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ PlayerSettings:
ps4ShareFilePath:
ps4ShareOverlayImagePath:
ps4PrivacyGuardImagePath:
ps4ExtraSceSysFile:
ps4NPtitleDatPath:
ps4RemotePlayKeyAssignment: -1
ps4RemotePlayKeyMappingDir:
Expand Down Expand Up @@ -626,6 +627,8 @@ PlayerSettings:
ps4disableAutoHideSplash: 0
ps4videoRecordingFeaturesUsed: 0
ps4contentSearchFeaturesUsed: 0
ps4CompatibilityPS5: 0
ps4GPU800MHz: 1
ps4attribEyeToEyeDistanceSettingVR: 0
ps4IncludedModules: []
ps4attribVROutputEnabled: 0
Expand Down

0 comments on commit 03f85ef

Please sign in to comment.