Skip to content

Commit 711b221

Browse files
author
Stephen Hodgson
committed
updated uNet example scripts.
1 parent b1fc46f commit 711b221

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

Assets/HoloToolkit-Examples/SharingWithUNET/Scripts/GenericNetworkTransmitter.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4+
using System;
45
using UnityEngine;
56
using HoloToolkit.Unity;
67

@@ -20,7 +21,6 @@ namespace HoloToolkit.Examples.SharingWithUNET
2021
/// </summary>
2122
public class GenericNetworkTransmitter : Singleton<GenericNetworkTransmitter>
2223
{
23-
2424
[Tooltip("The connection port on the machine to use.")]
2525
public int SendConnectionPort = 11000;
2626

@@ -29,12 +29,12 @@ public class GenericNetworkTransmitter : Singleton<GenericNetworkTransmitter>
2929
/// </summary>
3030
/// <param name="data">The data that arrived.</param>
3131
public delegate void OnDataReady(byte[] data);
32-
public event OnDataReady dataReadyEvent;
32+
public event OnDataReady DataReadyEvent;
3333

3434
/// <summary>
3535
/// The server to connect to when data is needed.
3636
/// </summary>
37-
private string serverIP;
37+
private string serverIp = string.Empty;
3838

3939
/// <summary>
4040
/// Tracks if we have a connection request outstanding.
@@ -58,10 +58,10 @@ public void SetData(byte[] data)
5858
/// <summary>
5959
/// Tells us who to contact if we need data.
6060
/// </summary>
61-
/// <param name="ServerIP"></param>
62-
public void SetServerIP(string ServerIP)
61+
/// <param name="_serverIp"></param>
62+
public void SetServerIp(string _serverIp)
6363
{
64-
serverIP = ServerIP.Trim();
64+
serverIp = _serverIp.Trim();
6565
}
6666

6767
/// <summary>
@@ -193,12 +193,6 @@ private async void RcvNetworkConnectedHandler(IAsyncAction asyncInfo, AsyncStatu
193193
else
194194
{
195195
Debug.Log("Failed to establish connection for rcv. Error Code: " + asyncInfo.ErrorCode);
196-
// In the failure case we'll requeue the data and wait before trying again.
197-
198-
199-
// And set the defer time so the update loop can do the 'Unity things'
200-
// on the main Unity thread.
201-
Invoke("RequestAndGetAnchor", timeToDeferFailedConnections);
202196
}
203197

204198
networkConnection.Dispose();
@@ -210,7 +204,7 @@ public void ConfigureAsServer()
210204
{
211205
Debug.Log("This script is not intended to be run from the Unity Editor");
212206
// In order to avoid compiler warnings in the Unity Editor we have to access a few of our fields.
213-
Debug.Log(string.Format("serverIP = {0} waitingForConnection = {1} mostRecentDataBuffer = {2}", serverIP, waitingForConnection, mostRecentDataBuffer == null ? "No there" : "there"));
207+
Debug.Log(string.Format("serverIP = {0} waitingForConnection = {1} mostRecentDataBuffer = {2}", serverIp, waitingForConnection, mostRecentDataBuffer == null ? "No there" : "there"));
214208
}
215209
private void ConnectListener() {}
216210
#endif

Assets/HoloToolkit-Examples/SharingWithUNET/Scripts/UNetAnchorManager.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using HoloToolkit.Unity;
88
using System;
99

10-
#if UNITY_EDITOR || UNITY_WSA
10+
#if UNITY_WSA
1111
using UnityEngine.VR.WSA.Sharing;
1212
using UnityEngine.VR.WSA;
1313
using UnityEngine.VR.WSA.Persistence;
@@ -152,7 +152,7 @@ private void Start()
152152
return;
153153
}
154154

155-
networkTransmitter.dataReadyEvent += NetworkTransmitter_dataReadyEvent;
155+
networkTransmitter.DataReadyEvent += NetworkTransmitter_dataReadyEvent;
156156
}
157157

158158
/// <summary>
@@ -173,7 +173,7 @@ private void NetworkTransmitter_dataReadyEvent(byte[] data)
173173
/// </summary>
174174
public void CreateAnchor()
175175
{
176-
#if UNITY_EDITOR || UNITY_WSA
176+
#if UNITY_WSA
177177
objectToAnchor = SharedCollection.Instance.gameObject;
178178
WorldAnchorTransferBatch watb = new WorldAnchorTransferBatch();
179179
WorldAnchor worldAnchor = objectToAnchor.GetComponent<WorldAnchor>();
@@ -202,15 +202,15 @@ public void WaitForAnchor()
202202
/// Attempts to attach to an anchor by anchorName in the local store..
203203
/// </summary>
204204
/// <returns>True if it attached, false if it could not attach</returns>
205-
private bool AttachToCachedAnchor(string AnchorName)
205+
private bool AttachToCachedAnchor(string anchorName)
206206
{
207-
#if UNITY_EDITOR || UNITY_WSA
207+
#if UNITY_WSA
208208
WorldAnchorStore anchorStore = WorldAnchorManager.Instance.AnchorStore;
209-
Debug.Log("Looking for " + AnchorName);
209+
Debug.Log("Looking for " + anchorName);
210210
string[] ids = anchorStore.GetAllIds();
211211
for (int index = 0; index < ids.Length; index++)
212212
{
213-
if (ids[index] == AnchorName)
213+
if (ids[index] == anchorName)
214214
{
215215
Debug.Log("Using what we have");
216216
anchorStore.Load(ids[index], objectToAnchor);
@@ -232,7 +232,7 @@ private void WriteBuffer(byte[] data)
232232
exportingAnchorBytes.AddRange(data);
233233
}
234234

235-
#if UNITY_EDITOR || UNITY_WSA
235+
#if UNITY_WSA
236236
private void Update()
237237
{
238238
if (gotOne)

0 commit comments

Comments
 (0)