Skip to content

Commit 4be4c32

Browse files
Merge pull request #513 from StephenHodgson/HTK-Sharing
HTK - Sharing Updates
2 parents 3f3cafb + 629d65a commit 4be4c32

19 files changed

+1188
-329
lines changed

Assets/HoloToolkit/Sharing/Prefabs/Sharing.prefab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ MonoBehaviour:
5959
AutoDiscoverServer: 0
6060
PingIntervalSec: 2
6161
IsAudioEndpoint: 1
62+
ShowDetailedLogs: 0
6263
--- !u!114 &114000013602799446
6364
MonoBehaviour:
6465
m_ObjectHideFlags: 1

Assets/HoloToolkit/Sharing/README.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Users can also collaborate with other users (who are also using multiple devices
99

1010
- [Features](#features)
1111
- [Configuration](#configuration)
12+
- [Troubleshooting](#troubleshooting)
1213
- [Plugins](#plugins)
1314
- [Prefabs](#prefabs)
1415
- [Scripts](#scripts)
@@ -105,6 +106,25 @@ Ensure you have the following capabilities set in Player Settings -> Windows Sto
105106

106107
Install or run the server instance.
107108

109+
### Troubleshooting
110+
---
111+
- Double check the Server Address on your sharing stage component in your scene matches the address shown in the sharing service console.
112+
- Make sure all devices are connected to the same Wireless Local Area Network.
113+
- Ensure all firewall settings are correct. Windows firewall gives you options to enable/disable by network type (private, public, home), make sure you're enabling the firewall for your connection's type.
114+
115+
####Invalid Schema Version
116+
117+
```
118+
SharingService [..\..\Source\Common\Private\SessionListHandshakeLogic.cpp (67)]:
119+
***************************************************************
120+
List Server Handshake Failed: Invalid schema version.
121+
Expected: 17, got 15
122+
Please sync to latest XTools
123+
***************************************************************
124+
```
125+
126+
- Ensure you're using the latest binaries of the sharing service found at `HoloToolkit-Unity\External\HoloToolkit\Sharing\Server`.
127+
108128
### [Plugins](Plugins)
109129
---
110130
Contains compiled architecture specific binaries for SharingClient.dll which are required by the Unity application for accessing sharing APIs.
@@ -299,8 +319,14 @@ Broadcasts the head transform of the local user to other users in the session, a
299319
#### RoomTest.cs
300320
Test class for demonstrating creating rooms and anchors.
301321

302-
#### SpawnTestKeyboardSpawning.cs
303-
Class that handles spawning sync objects on keyboard presses, for the `SpawningTest.scene`.
322+
#### SyncObjectSpawner.cs
323+
Class that handles spawning and deleteing sync objects for the `SpawningTest.scene`. Uses the `KeywordManager` to spawn objects using voice and keyboard input.
324+
325+
|Voice Command|Key Command|Description|
326+
|---|---|---|
327+
| Spawn Basic | Key `I`| Spawns a cube with a `SyncSpawnedObject` basic sync model.|
328+
| Spawn Custom | Key `O`| Spawns a sphere with a `SyncSpawnTestSphere` custom sync model.|
329+
| Delete Object | Key `M`| Deletes both sync model types.|
304330

305331
#### SyncSpawnTestSphere.cs
306332
Class that demonstrates a custom class using sync model attributes.
@@ -310,13 +336,14 @@ Used to demonstrate how to get notifications when users leave and enter room.
310336

311337
### [Tests](Tests/Scenes)
312338
---
313-
Tests related to the sharing features. To use the scene:
339+
Tests related to the sharing features. To use the each scene:
314340

315341
1. Navigate to the Tests folder.
316342
2. Double click on the test scene you wish to explore.
317343
3. Either click "Play" in the unity editor or File -> Build Settings.
318344
4. Add Open Scenes, Platform -> Windows Store, SDK -> Universal 10, Build Type -> D3D, Check 'Unity C# Projects'.
319-
5. Click 'Build' and create an App folder. When compile is done, open the solution and deploy to device.
345+
5. Enable all required [capabilities](configuration).
346+
6. Click 'Build' and create an App folder. When compile is done, open the solution and deploy to device.
320347

321348
#### SharingTest.unity
322349
This test demonstrates how to use the Sharing prefabs for networking and sharing custom messages with clients.
@@ -337,12 +364,12 @@ It also demonstrates how to upload and download new anchors.
337364
3. **RoomTest.cs** shows how to create, join, and leave rooms; also shows how to create and download anchors.
338365

339366
#### SharingSpawnTest.unity
340-
This test demonstrates how to spawn sync objects in your scene and across your networked clients.
367+
This test demonstrates how to spawn and delete sync objects in your scene and across your networked clients.
341368

342369
1. Ensure to launch the sharing service using: HoloToolkit -> Launch Sharing service
343370
2. Enter the IP address displayed in the console window into the Server Address of the Sharing object.
344371
3. **PrefabSpawnManager.cs** enables you to store prefab references to use when spawning.
345-
4. **SpawnTestKeyboardSpawning** demonstrates how to spawn sync objects, as well as custom class types.
372+
4. **SyncObjectSpawner.cs** demonstrates how to spawn and delete sync objects, as well as custom class types.
346373

347374
---
348375
##### [Go back up to the table of contents](#table-of-contents)

Assets/HoloToolkit/Sharing/Scripts/SharingStage.cs

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class SharingStage : Singleton<SharingStage>
2222
/// Default username to use when joining a session.
2323
/// </summary>
2424
/// <remarks>User code should set the user name by setting the UserName property.</remarks>
25-
private const string DefaultUserName = "User0";
25+
private const string DefaultUserName = "User ";
2626

2727
/// <summary>
2828
/// Set whether this app should be a Primary or Secondary client.
@@ -108,7 +108,14 @@ public class SharingStage : Singleton<SharingStage>
108108
/// </summary>
109109
private DiscoveryClientAdapter discoveryClientAdapter;
110110

111+
/// <summary>
112+
/// The current ping interval during AutoDiscovery updates.
113+
/// </summary>
111114
private float pingIntervalCurrent;
115+
116+
/// <summary>
117+
/// True when AutoDiscovery is actively searching, otherwise false.
118+
/// </summary>
112119
private bool isTryingToFindServer;
113120

114121
[Tooltip("Show Detailed Information for server connections")]
@@ -128,7 +135,7 @@ public string UserName
128135
}
129136
set
130137
{
131-
using (XString userName = new XString(value))
138+
using (var userName = new XString(value))
132139
{
133140
Manager.SetUserName(userName);
134141
}
@@ -143,14 +150,30 @@ public NetworkConnection Connection
143150
{
144151
get
145152
{
146-
if (networkConnection == null)
153+
if (networkConnection == null && Manager != null)
147154
{
148155
networkConnection = Manager.GetServerConnection();
149156
}
150157
return networkConnection;
151158
}
152159
}
153160

161+
/// <summary>
162+
/// Returns true if connected to a Sharing Service server.
163+
/// </summary>
164+
public bool IsConnected
165+
{
166+
get
167+
{
168+
if (Manager != null && Connection != null)
169+
{
170+
return Connection.IsConnected();
171+
}
172+
173+
return false;
174+
}
175+
}
176+
154177
protected override void Awake()
155178
{
156179
base.Awake();
@@ -171,8 +194,6 @@ protected override void Awake()
171194

172195
protected override void OnDestroy()
173196
{
174-
base.OnDestroy();
175-
176197
if (discoveryClient != null)
177198
{
178199
discoveryClient.RemoveListener(discoveryClientAdapter);
@@ -227,6 +248,8 @@ protected override void OnDestroy()
227248

228249
// Forces a garbage collection to try to clean up any additional reference to SWIG-wrapped objects
229250
GC.Collect();
251+
252+
base.OnDestroy();
230253
}
231254

232255
private void LateUpdate()
@@ -245,7 +268,7 @@ private void LateUpdate()
245268

246269
private void Connect()
247270
{
248-
ClientConfig config = new ClientConfig(ClientRole);
271+
var config = new ClientConfig(ClientRole);
249272
config.SetIsAudioEndpoint(IsAudioEndpoint);
250273
config.SetLogWriter(logWriter);
251274

@@ -272,9 +295,21 @@ private void Connect()
272295
SessionsTracker = new ServerSessionsTracker(Manager.GetSessionManager());
273296
SessionUsersTracker = new SessionUsersTracker(SessionsTracker);
274297

275-
using (XString userName = new XString(DefaultUserName))
298+
using (var userName = new XString(DefaultUserName))
276299
{
277-
Manager.SetUserName(userName);
300+
#if UNITY_WSA && !UNITY_EDITOR
301+
Manager.SetUserName(SystemInfo.deviceName);
302+
#else
303+
if (!string.IsNullOrEmpty(Environment.UserName))
304+
{
305+
Manager.SetUserName(Environment.UserName);
306+
}
307+
else
308+
{
309+
User localUser = Manager.GetLocalUser();
310+
Manager.SetUserName(userName + localUser.GetID().ToString());
311+
}
312+
#endif
278313
}
279314
}
280315

Assets/HoloToolkit/Sharing/Scripts/Spawning/PrefabSpawnManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class PrefabSpawnManager : SpawnManager<SyncSpawnedObject>
3232
/// </summary>
3333
/// <remarks>It is assumed that this list is the same on all connected applications.</remarks>
3434
[SerializeField]
35-
private List<PrefabToDataModel> spawnablePrefabs;
35+
private List<PrefabToDataModel> spawnablePrefabs = null;
3636

3737
private Dictionary<string, GameObject> typeToPrefab;
3838

Assets/HoloToolkit/Sharing/Scripts/Spawning/SpawnManager.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License. See LICENSE in the project root for license information.
44
//
55

6+
using System;
67
using UnityEngine;
78
using HoloToolkit.Sharing.SyncModel;
89

@@ -22,7 +23,22 @@ namespace HoloToolkit.Sharing.Spawning
2223

2324
protected virtual void Start()
2425
{
26+
// SharingStage should be valid at this point, but we may not be connected.
2527
NetworkManager = SharingStage.Instance;
28+
if (NetworkManager.IsConnected)
29+
{
30+
Connected();
31+
}
32+
else
33+
{
34+
NetworkManager.SharingManagerConnected += Connected;
35+
}
36+
}
37+
38+
protected virtual void Connected(object sender = null, EventArgs e = null)
39+
{
40+
NetworkManager.SharingManagerConnected -= Connected;
41+
2642
SetDataModelSource();
2743
RegisterToDataModel();
2844
}

Assets/HoloToolkit/Sharing/Scripts/Utilities/AutoJoinSession.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ private void Update()
5454
{
5555
if (SharingStage.Instance.ShowDetailedLogs)
5656
{
57-
Debug.LogFormat("Session conn {0} Sessions: {1}.", sessionsTracker.IsServerConnected.ToString(), sessionsTracker.Sessions.Count.ToString());
58-
Debug.Log("Looking for " + SessionName);
57+
Debug.LogFormat("AutoJoinSession: Session connected is {0} with {1} Sessions.", sessionsTracker.IsServerConnected.ToString(), sessionsTracker.Sessions.Count.ToString());
58+
Debug.Log("AutoJoinSession: Looking for " + SessionName);
5959
}
6060
bool sessionFound = false;
6161

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!1001 &100100000
4+
Prefab:
5+
m_ObjectHideFlags: 1
6+
serializedVersion: 2
7+
m_Modification:
8+
m_TransformParent: {fileID: 0}
9+
m_Modifications: []
10+
m_RemovedComponents: []
11+
m_ParentPrefab: {fileID: 0}
12+
m_RootGameObject: {fileID: 1460649626274452}
13+
m_IsPrefabParent: 1
14+
--- !u!1 &1460649626274452
15+
GameObject:
16+
m_ObjectHideFlags: 0
17+
m_PrefabParentObject: {fileID: 0}
18+
m_PrefabInternal: {fileID: 100100000}
19+
serializedVersion: 5
20+
m_Component:
21+
- component: {fileID: 4631490928263856}
22+
- component: {fileID: 23725207649169752}
23+
- component: {fileID: 102214044351826462}
24+
- component: {fileID: 114413180992801294}
25+
m_Layer: 0
26+
m_Name: AnchorText
27+
m_TagString: Untagged
28+
m_Icon: {fileID: 0}
29+
m_NavMeshLayer: 0
30+
m_StaticEditorFlags: 0
31+
m_IsActive: 1
32+
--- !u!4 &4631490928263856
33+
Transform:
34+
m_ObjectHideFlags: 1
35+
m_PrefabParentObject: {fileID: 0}
36+
m_PrefabInternal: {fileID: 100100000}
37+
m_GameObject: {fileID: 1460649626274452}
38+
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
39+
m_LocalPosition: {x: 0, y: 0.17, z: 0}
40+
m_LocalScale: {x: 0.005, y: 0.005, z: 0.005}
41+
m_Children: []
42+
m_Father: {fileID: 0}
43+
m_RootOrder: 0
44+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
45+
--- !u!23 &23725207649169752
46+
MeshRenderer:
47+
m_ObjectHideFlags: 1
48+
m_PrefabParentObject: {fileID: 0}
49+
m_PrefabInternal: {fileID: 100100000}
50+
m_GameObject: {fileID: 1460649626274452}
51+
m_Enabled: 1
52+
m_CastShadows: 1
53+
m_ReceiveShadows: 1
54+
m_MotionVectors: 1
55+
m_LightProbeUsage: 1
56+
m_ReflectionProbeUsage: 1
57+
m_Materials:
58+
- {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0}
59+
m_StaticBatchInfo:
60+
firstSubMesh: 0
61+
subMeshCount: 0
62+
m_StaticBatchRoot: {fileID: 0}
63+
m_ProbeAnchor: {fileID: 0}
64+
m_LightProbeVolumeOverride: {fileID: 0}
65+
m_ScaleInLightmap: 1
66+
m_PreserveUVs: 0
67+
m_IgnoreNormalsForChartDetection: 0
68+
m_ImportantGI: 0
69+
m_SelectedEditorRenderState: 3
70+
m_MinimumChartSize: 4
71+
m_AutoUVMaxDistance: 0.5
72+
m_AutoUVMaxAngle: 89
73+
m_LightmapParameters: {fileID: 0}
74+
m_SortingLayerID: 0
75+
m_SortingOrder: 0
76+
--- !u!102 &102214044351826462
77+
TextMesh:
78+
serializedVersion: 3
79+
m_ObjectHideFlags: 1
80+
m_PrefabParentObject: {fileID: 0}
81+
m_PrefabInternal: {fileID: 100100000}
82+
m_GameObject: {fileID: 1460649626274452}
83+
m_Text: No Server Connection
84+
m_OffsetZ: 0
85+
m_CharacterSize: 1
86+
m_LineSpacing: 1
87+
m_Anchor: 4
88+
m_Alignment: 1
89+
m_TabSize: 4
90+
m_FontSize: 48
91+
m_FontStyle: 0
92+
m_RichText: 1
93+
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
94+
m_Color:
95+
serializedVersion: 2
96+
rgba: 4294967295
97+
--- !u!114 &114413180992801294
98+
MonoBehaviour:
99+
m_ObjectHideFlags: 1
100+
m_PrefabParentObject: {fileID: 0}
101+
m_PrefabInternal: {fileID: 100100000}
102+
m_GameObject: {fileID: 1460649626274452}
103+
m_Enabled: 1
104+
m_EditorHideFlags: 0
105+
m_Script: {fileID: 11500000, guid: ac8d5b128a1d8204fb76c86f47b75912, type: 3}
106+
m_Name:
107+
m_EditorClassIdentifier:
108+
PivotAxis: 0

Assets/HoloToolkit/Sharing/Tests/Prefabs/AnchorText.prefab.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/HoloToolkit/Sharing/Tests/Prefabs/SpawnTestCube.prefab

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ MeshRenderer:
5050
m_PrefabInternal: {fileID: 100100000}
5151
m_GameObject: {fileID: 1000011931115288}
5252
m_Enabled: 1
53-
m_CastShadows: 1
54-
m_ReceiveShadows: 1
53+
m_CastShadows: 0
54+
m_ReceiveShadows: 0
5555
m_MotionVectors: 1
56-
m_LightProbeUsage: 1
57-
m_ReflectionProbeUsage: 1
56+
m_LightProbeUsage: 0
57+
m_ReflectionProbeUsage: 0
5858
m_Materials:
59-
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
59+
- {fileID: 2100000, guid: c9eb9258e335f144fae9e9e50e1fe664, type: 2}
6060
m_StaticBatchInfo:
6161
firstSubMesh: 0
6262
subMeshCount: 0

0 commit comments

Comments
 (0)