Skip to content
This repository was archived by the owner on Oct 20, 2021. It is now read-only.

Commit 5657970

Browse files
authored
Release 0.2.3 (#197)
* Release 0.2.3 * updating gdk tools config * Fix mapbuilder in editor (#198) * 2019.1 no longer allows temp scenes in editor mode. Refactored code to work again * Update link.xml * disabled burst compilation (#199) * Make the mobile connector use the Dev Auth Token that's passed through as an argument. (#201) * updated changelog * enable burst just for iOS * remove new line * Deferring the client-worker destroy by a frame (#200) * deferring player destroy by a frame * updating pin * updating pinned version
1 parent a29bc2e commit 5657970

File tree

21 files changed

+174
-67
lines changed

21 files changed

+174
-67
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
## `0.2.3` - 2019-06-12
6+
57
### Changed
68

79
- Upgraded the project to be compatible with `2019.1.3f1`. [#185](https://github.com/spatialos/gdk-for-unity-fps-starter-project/pull/185)
@@ -39,6 +41,11 @@
3941

4042
- Fixed a bug where your own gun would not appear until after you moved around for a while.
4143

44+
### Internal
45+
46+
- Disabled Burst compilation for all platforms except for iOS, because Burst throws benign errors when building workers for other platforms than the one you are currently using. [#977](https://github.com/spatialos/gdk-for-unity/pull/977)
47+
- Enabled Burst compilation for iOS, because disabling results in an invalid XCode project. [#975](https://github.com/spatialos/gdk-for-unity/pull/975)
48+
4249
## `0.2.1` - 2019-04-15
4350

4451
### Changed

gdk.pinned

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8708f8b47e323b5b54dcb8e4528a05ad5ee81b0b
1+
eae6cf5dcdb72655bde2121614001cdf1dde51bf

packer.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"package_name": "gdk-for-unity-fps-starter-project",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"git_packages": [
55
{
66
"clone_url": "[email protected]:spatialos/gdk-for-unity-fps-starter-project.git",
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"SchemaStdLibDir": "../../build/dependencies/schema/standard_library",
3-
"SchemaSourceDirs": [
4-
"../../schema"
5-
],
3+
"SchemaSourceDirs": [],
64
"CodegenOutputDir": "Assets/Generated/Source",
7-
"RuntimeIp": "",
5+
"DescriptorOutputDir": "../../build/assembly/schema",
86
"DevAuthTokenDir": "Resources",
9-
"DevAuthTokenLifetimeDays": 1
7+
"DevAuthTokenLifetimeDays": 1,
8+
"SaveDevAuthTokenToFile": false
109
}

workers/unity/Assets/Fps/Scripts/Config/MapBuilder.cs

Lines changed: 65 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Collections.Generic;
44
using Improbable.Gdk.Core;
55
using UnityEngine;
6-
using UnityEngine.Profiling;
76
using UnityEngine.SceneManagement;
87
using Object = UnityEngine.Object;
98
using Random = System.Random;
@@ -18,7 +17,7 @@ public class MapBuilder
1817
private int layers;
1918
private Random random;
2019
private Scene tempScene;
21-
private Scene activeScene;
20+
private Scene mainScene;
2221

2322
private GameObject groundTile;
2423
private GameObject groundEdge;
@@ -67,8 +66,12 @@ public MapBuilder(MapTemplate mapTemplate, GameObject parentGameObject)
6766

6867
layers = worldLayers;
6968
random = new Random(seed.GetHashCode());
70-
tempScene = SceneManager.CreateScene(parentGameObject.name, new CreateSceneParameters(LocalPhysicsMode.None));
71-
activeScene = SceneManager.GetActiveScene();
69+
if (Application.isPlaying)
70+
{
71+
tempScene = SceneManager.CreateScene(parentGameObject.name,
72+
new CreateSceneParameters(LocalPhysicsMode.None));
73+
mainScene = SceneManager.GetActiveScene();
74+
}
7275

7376
if (!TryLoadResources())
7477
{
@@ -81,45 +84,44 @@ public MapBuilder(MapTemplate mapTemplate, GameObject parentGameObject)
8184
InitializeGroupsAndComponents();
8285

8386
// Initialize tiles
84-
SceneManager.SetActiveScene(tempScene);
85-
foreach (var tileCollection in mapTemplate.tileCollections)
87+
using (new SceneScope(tempScene))
8688
{
87-
tileCollection.LoadAndOptimizeTiles();
88-
}
89-
90-
mapTemplate.defaultTileCollection.LoadAndOptimizeTiles();
91-
SceneManager.SetActiveScene(activeScene);
89+
foreach (var tileCollection in mapTemplate.tileCollections)
90+
{
91+
tileCollection.LoadAndOptimizeTiles();
92+
}
9293

93-
yield return null;
94+
mapTemplate.defaultTileCollection.LoadAndOptimizeTiles();
9495

95-
var originalPosition = parentGameObject.transform.position;
96-
var originalRotation = parentGameObject.transform.rotation;
97-
parentGameObject.transform.position = Vector3.zero;
98-
parentGameObject.transform.rotation = Quaternion.identity;
96+
var originalPosition = parentGameObject.transform.position;
97+
var originalRotation = parentGameObject.transform.rotation;
98+
parentGameObject.transform.position = Vector3.zero;
99+
parentGameObject.transform.rotation = Quaternion.identity;
99100

100-
yield return PlaceTiles();
101+
yield return PlaceTiles();
101102

102-
SceneManager.SetActiveScene(tempScene);
103+
PlaceGround();
104+
FillSurround();
103105

104-
PlaceGround();
105-
FillSurround();
106+
spawnPointSystemTransform.gameObject.GetComponent<SpawnPoints>()?.SetSpawnPoints();
106107

107-
spawnPointSystemTransform.gameObject.GetComponent<SpawnPoints>()?.SetSpawnPoints();
108+
parentGameObject.transform.position = originalPosition;
109+
parentGameObject.transform.rotation = originalRotation;
108110

109-
parentGameObject.transform.position = originalPosition;
110-
parentGameObject.transform.rotation = originalRotation;
111+
// Cleanup
112+
foreach (var tileCollection in mapTemplate.tileCollections)
113+
{
114+
tileCollection.Clear();
115+
}
111116

112-
// Cleanup
113-
foreach (var tileCollection in mapTemplate.tileCollections)
114-
{
115-
tileCollection.Clear();
117+
mapTemplate.defaultTileCollection.Clear();
116118
}
117119

118-
mapTemplate.defaultTileCollection.Clear();
119-
120120
// Merge building temp scene into active scene
121-
SceneManager.SetActiveScene(activeScene);
122-
SceneManager.MergeScenes(tempScene, activeScene);
121+
if (Application.isPlaying)
122+
{
123+
SceneManager.MergeScenes(tempScene, mainScene);
124+
}
123125
}
124126

125127
private void InitializeGroupsAndComponents()
@@ -281,7 +283,6 @@ private IEnumerator PlaceTiles()
281283

282284
// Tiles are built in a spiral manner from the centre outward to ensure increasing the # of tile layers doesn't
283285
// alter the existing tile types.
284-
SceneManager.SetActiveScene(tempScene);
285286
for (var i = 0; i < tileCount; i++)
286287
{
287288
// -layers < x <= layers AND -layers < y <= layers
@@ -300,17 +301,16 @@ private IEnumerator PlaceTiles()
300301

301302
tileCoord += diff;
302303

303-
if (DateTime.UtcNow.Subtract(timeStart) >= timeLimit)
304+
if (Application.isPlaying && DateTime.UtcNow.Subtract(timeStart) >= timeLimit)
304305
{
305-
SceneManager.SetActiveScene(activeScene);
306-
yield return null;
307-
timeStart = DateTime.UtcNow;
308-
SceneManager.SetActiveScene(tempScene);
306+
using (new SceneScope(mainScene))
307+
{
308+
yield return null;
309+
timeStart = DateTime.UtcNow;
310+
}
309311
}
310312
}
311313

312-
SceneManager.SetActiveScene(activeScene);
313-
314314
tileParentTransform.position = new Vector3
315315
{
316316
x = tileParentTransform.position.x,
@@ -442,5 +442,31 @@ public static IEnumerator GenerateMap(
442442

443443
worker.LevelInstance = levelInstance;
444444
}
445+
446+
private class SceneScope : IDisposable
447+
{
448+
private readonly Scene activeScene;
449+
450+
public SceneScope(Scene newActive)
451+
{
452+
#if UNITY_EDITOR
453+
if (Application.isPlaying)
454+
#endif
455+
{
456+
activeScene = SceneManager.GetActiveScene();
457+
SceneManager.SetActiveScene(newActive);
458+
}
459+
}
460+
461+
public void Dispose()
462+
{
463+
#if UNITY_EDITOR
464+
if (Application.isPlaying)
465+
#endif
466+
{
467+
SceneManager.SetActiveScene(activeScene);
468+
}
469+
}
470+
}
445471
}
446472
}

workers/unity/Assets/Fps/Scripts/GameLogic/StateMachine/Session/ResultsState.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,13 @@ public override void Tick()
4949

5050
var results = trackPlayerSystem.PlayerResults;
5151
var playerRank = results.FirstOrDefault(res => res.PlayerName == Blackboard.PlayerName).Rank;
52-
Debug.Log($"playerRank {playerRank}");
53-
Debug.Log($"player name {Blackboard.PlayerName}");
5452

5553
ScreenManager.ResultsScreenDoneButton.onClick.AddListener(Restart);
5654
ScreenManager.InformOfResults(results, playerRank);
5755
Manager.ShowFrontEnd();
5856
ScreenManager.SwitchToResultsScreen();
5957

60-
UnityObjectDestroyer.Destroy(Blackboard.ClientConnector);
58+
Blackboard.ClientConnector.DisconnectPlayer();
6159
Blackboard.ClientConnector = null;
6260
}
6361
}

workers/unity/Assets/Fps/Scripts/SetupLogic/ClientWorkerConnector.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
using UnityEngine;
77
using Improbable.Gdk.GameObjectCreation;
88
using Improbable.Gdk.PlayerLifecycle;
9+
using Improbable.Worker.CInterop;
910
using Improbable.Worker.CInterop.Alpha;
11+
using Unity.Entities;
1012

1113
namespace Fps
1214
{
@@ -41,6 +43,11 @@ public bool HasConnected()
4143
return Worker != null;
4244
}
4345

46+
public void DisconnectPlayer()
47+
{
48+
StartCoroutine(PrepareDestroy());
49+
}
50+
4451
protected override string GetWorkerType()
4552
{
4653
return WorkerUtils.UnityClient;
@@ -149,6 +156,12 @@ public override void Dispose()
149156
base.Dispose();
150157
}
151158

159+
private IEnumerator PrepareDestroy()
160+
{
161+
yield return DeferredDisposeWorker();
162+
Destroy(gameObject);
163+
}
164+
152165
private void SendRequest()
153166
{
154167
var serializedArgs = Encoding.ASCII.GetBytes(playerName);

workers/unity/Assets/Fps/Scripts/SetupLogic/MobileWorkerConnector.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ private void InitializeClient()
120120
PlayerPrefs.DeleteKey(HostIpPlayerPrefsKey);
121121
}
122122

123+
var devAuthToken = CommandLineUtility.GetCommandLineValue(arguments, RuntimeConfigNames.DevAuthTokenKey, string.Empty);
124+
if (!string.IsNullOrEmpty(devAuthToken))
125+
{
126+
PlayerPrefs.SetString(RuntimeConfigNames.DevAuthTokenKey, devAuthToken);
127+
}
128+
123129
PlayerPrefs.Save();
124130
}
125131

workers/unity/Assets/link.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
<assembly fullname="Improbable.Gdk.ObjectPooling" preserve="all"/>
1010
<assembly fullname="Improbable.Gdk.Ragdoll" preserve="all"/>
1111
<assembly fullname="Improbable.Gdk.StandardTypes" preserve="all"/>
12+
<assembly fullname="Unity.Entities.Hybrid">
13+
<type fullname="Unity.Entities.GameObjectEntity" preserve="all"/>
14+
</assembly>
1215
</linker>

workers/unity/Packages/com.improbable.gdk.deploymentmanager/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.improbable.gdk.deploymentmanager",
33
"displayName": "SpatialOS GDK Deployment Manager",
4-
"version": "0.2.2",
4+
"version": "0.2.3",
55
"unity": "2019.1",
66
"author": "Improbable Worlds Ltd",
77
"description": "SpatialOS GDK Deployment Manager. Made by Improbable.",

0 commit comments

Comments
 (0)