Skip to content
This repository was archived by the owner on Dec 5, 2018. It is now read-only.

Commit a3dea24

Browse files
committed
upgraded to SpatialOS 10.3.0
1 parent 34699a5 commit a3dea24

36 files changed

+200
-513
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Starter Project
22
---
33

4-
*Copyright Improbable 2017*
4+
*Copyright Improbable Worlds Ltd, 2017*
55

6-
- *GitHub Repository*: [github.com/spatialos/StarterProject](https://github.com/spatialos/StarterProject)
6+
- *GitHub repository*: [https://github.com/spatialos/StarterProject](https://github.com/spatialos/StarterProject)
77

88
---
99

@@ -13,12 +13,14 @@ This is a SpatialOS starter project with useful core features that you can exten
1313

1414
It contains:
1515

16-
* A Player spawned on client connection.
17-
* A Cube spawned through a snapshot via an entity template method and Unity prefab.
18-
* Other features of the [BlankProject](https://github.com/spatialos/BlankProject).
16+
* A Player spawned on client connection as per the [Unity Client Lifecycle Guide](https://spatialos.improbable.io/docs/reference/latest/tutorials/client-lifecycle).
17+
* A Cube spawned through a snapshot via an entity template method and an Unity prefab.
18+
* The rest of the features included in the [BlankProject](https://github.com/spatialos/BlankProject).
1919

20-
## Using the Starter Project
20+
If you run into problems, or want to give us feedback, please visit the [SpatialOS forums](https://forums.improbable.io/).
2121

22-
[SpatialOS documentation](https://spatialos.improbable.io/docs/).
22+
## Running the project
2323

24-
To report bugs or to give feedback on this project, please contact SpatialOS Support.
24+
To run the project locally, first build it by running `spatial worker build`, then start the server with `spatial local start`. You can connect a client by opening the Unity project and pressing the play button, or by running `spatial local worker launch UnityClient default`. See the [documentation](https://spatialos.improbable.io/docs/reference/latest/developing/local/run) for more details.
25+
26+
To deploy the project to the cloud, first build it by running `spatial worker build -t=deployment`, then upload the assembly with `spatial cloud upload <assembly name>`, and finally deploy it with `spatial cloud launch <assembly name> <launch configuration file> <deployment name> --snapshot=<snapshot file>`. You can obtain and share links to connect to the deployment from the [console](http://console.improbable.io/projects). See the [documentation](https://spatialos.improbable.io/docs/reference/latest/developing/deploy-an-application) for more details.

schema/improbable/global/ClientAuthorityCheck.schema renamed to schema/improbable/core/ClientAuthorityCheck.schema

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package improbable.global;
1+
package improbable.core;
22

33
component ClientAuthorityCheck {
44
id = 1002;

schema/improbable/global/PlayerCreation.schema renamed to schema/improbable/core/PlayerCreation.schema

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package improbable.global;
1+
package improbable.core;
22

33
type CreatePlayerRequest {}
44
type CreatePlayerResponse {}

schema/improbable/global/Quaternion.schema renamed to schema/improbable/core/Quaternion.schema

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package improbable.global;
1+
package improbable.core;
22

33
type Quaternion {
44
float x = 1;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package improbable.core;
2+
3+
import "improbable/core/Quaternion.schema";
4+
5+
component WorldTransform {
6+
id = 1000;
7+
EntityPosition position = 1;
8+
improbable.core.Quaternion rotation = 2;
9+
}

schema/improbable/global/WorldTransform.schema

Lines changed: 0 additions & 9 deletions
This file was deleted.

workers/gsim/spatialos.gsim.build.json

Lines changed: 0 additions & 61 deletions
This file was deleted.

workers/unity/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ sysinfo.txt
4747
*.apk
4848
*.unitypackage
4949

50-
.idea/
50+
.idea/
51+
.vs/
Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,81 @@
1-
using System;
1+
using Assets.Gamelogic.Core;
2+
using Improbable.Unity;
3+
using Improbable.Unity.EditorTools.Build;
4+
using System;
25
using System.IO;
36
using System.Linq;
4-
using Assets.Gamelogic.Global;
5-
using Improbable.Unity;
67
using UnityEditor;
7-
using Improbable.Unity.EditorTools.Build;
88

99
namespace Assets.Editor
1010
{
1111
[InitializeOnLoad]
1212
public class PlayerBuildProcess : IPlayerBuildEvents
1313
{
14+
// Install the custom event handler
15+
static PlayerBuildProcess()
16+
{
17+
/* Each time you use Build development players or Build deployment players, SimpleBuildSystem.CreatePlayerBuildEventsAction
18+
is called, and a new PlayerBuildProcess event handler will be created */
19+
SimpleBuildSystem.CreatePlayerBuildEventsAction = () => new PlayerBuildProcess();
20+
// Configure the Unity editor build settings for running multiple scenes with the editor
21+
EditorBuildSettings.scenes = FormatAsBuildSettingsScenes(GetAllScenes());
22+
}
23+
1424
#region Implement IPlayerBuildEvents
1525

26+
// Overridden function to load (and optionally modify) scenes, then return an array of scene paths to be built into the worker
1627
public string[] GetScenes(WorkerPlatform workerType)
1728
{
29+
string[] scenePaths;
30+
1831
switch (workerType)
1932
{
2033
case WorkerPlatform.UnityClient:
21-
return FormatSceneList(BuildSettings.ClientScenes, BuildSettings.ClientDefaultActiveScene);
34+
scenePaths = FormatSceneList(BuildSettings.ClientScenes, BuildSettings.ClientDefaultActiveScene);
35+
break;
2236
case WorkerPlatform.UnityWorker:
23-
return FormatSceneList(BuildSettings.WorkerScenes, BuildSettings.WorkerDefaultActiveScene);
37+
scenePaths = FormatSceneList(BuildSettings.WorkerScenes, BuildSettings.WorkerDefaultActiveScene);
38+
break;
2439
default:
2540
throw new Exception("Attempting to get scenes for unrecognised worker platform");
2641
}
27-
}
28-
29-
private string[] FormatSceneList(string[] sceneList, string defaultActiveScene)
30-
{
31-
return sceneList.OrderBy(scene => scene != defaultActiveScene).Select(FormatSceneName).ToArray();
32-
}
3342

34-
private string FormatSceneName(string sceneName)
35-
{
36-
return Path.Combine(BuildSettings.SceneDirectory, sceneName) + ".unity";
43+
return scenePaths;
3744
}
3845

46+
// Overridden function called before any workers are built - use to do preliminary work such as saving scenes
3947
public void BeginBuild() { }
4048

49+
// Overridden function called after all workers are built, even if errors occurred - use to clean up anything done in BeginBuild
4150
public void EndBuild() { }
4251

52+
// Overridden function - use to do work such as copying additional files that need to be packaged with the worker
4353
public void BeginPackage(WorkerPlatform workerType, BuildTarget target, Config config, string packagePath) { }
4454

4555
#endregion
4656

47-
static PlayerBuildProcess()
57+
// Map array of scene paths to custom Unity type for saving as editor build settings
58+
private static EditorBuildSettingsScene[] FormatAsBuildSettingsScenes(string[] scenePaths)
4859
{
49-
SimpleBuildSystem.CreatePlayerBuildEventsAction = () => new PlayerBuildProcess();
60+
return scenePaths.Select(scenePath => new EditorBuildSettingsScene(scenePath, true)).ToArray();
61+
}
62+
63+
// Get all scenes for the purposes of adding to the Unity editor build settings
64+
private static string[] GetAllScenes()
65+
{
66+
return BuildSettings.ClientScenes.Union(BuildSettings.WorkerScenes).Select(FormatSceneName).ToArray();
67+
}
68+
69+
// Ensures scene specified as default is listed (and therefore loaded) first
70+
private static string[] FormatSceneList(string[] sceneList, string defaultActiveScene)
71+
{
72+
return sceneList.OrderBy(scene => scene != defaultActiveScene).Select(FormatSceneName).ToArray();
73+
}
74+
75+
// Formats scene name as it appears in your Unity project directory
76+
private static string FormatSceneName(string sceneName)
77+
{
78+
return Path.Combine(BuildSettings.SceneDirectory, sceneName) + ".unity";
5079
}
5180
}
52-
}
81+
}

workers/unity/Assets/Editor/SnapshotMenu.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
using System.Collections.Generic;
2-
using System.IO;
1+
using Assets.Gamelogic.Core;
32
using Assets.Gamelogic.EntityTemplates;
43
using Improbable;
54
using Improbable.Worker;
6-
using UnityEngine;
75
using JetBrains.Annotations;
6+
using System.Collections.Generic;
7+
using System.IO;
88
using UnityEditor;
9-
using Assets.Gamelogic.Global;
9+
using UnityEngine;
1010

1111
namespace Assets.Editor
1212
{

0 commit comments

Comments
 (0)