Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dbastienMS committed Jul 18, 2017
2 parents 547ec95 + 4d01fbb commit 9d1fdc5
Show file tree
Hide file tree
Showing 31 changed files with 1,297 additions and 359 deletions.
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System.Collections;
using UnityEngine;
using UnityEngine.Networking;

Expand Down Expand Up @@ -94,24 +95,37 @@ private void MaybeInitAsServer()
return;
}

StartCoroutine(InitAsServer());
}

private IEnumerator InitAsServer()
{
Debug.Log("Acting as host");
// StopBroadcast will also 'StopListening'
StopBroadcast();

// Work-around when building to the HoloLens with "Compile with .NET Native tool chain".
// Need a frame of delay after StopBroadcast() otherwise clients won't connect.
yield return null;

// Starting as a 'host' makes us both a client and a server.
// There are nuances to this in UNet's sync system, so do make sure
// to test behavior of your networked objects on both a host and a client
// device.
NetworkManager.singleton.StartHost();

// Work-around when building to the HoloLens with "Compile with .NET Native tool chain".
// Need a frame of delay between StartHost() and StartAsServer() otherwise clients won't connect.
yield return null;

// Start broadcasting for other clients.
StartAsServer();

#if !UNITY_EDITOR
// Start creating an anchor.
UNetAnchorManager.Instance.CreateAnchor();
#else
Debug.LogWarning("This script will need modification to work in the Unity Editor");
Debug.LogWarning("This script will need modification to work in the Unity Editor");
#endif
}

Expand Down
Expand Up @@ -29,6 +29,7 @@ private enum ImportExportState
Start,
Failed,
Ready,
RoomApiInitializing,
RoomApiInitialized,
AnchorEstablished,
// AnchorStore states
Expand Down Expand Up @@ -489,6 +490,7 @@ private void ResetState()
/// </summary>
private IEnumerator InitRoomApi()
{
currentState = ImportExportState.RoomApiInitializing;
// First check if there is a current room
currentRoom = roomManager.GetCurrentRoom();

Expand All @@ -497,6 +499,7 @@ private IEnumerator InitRoomApi()
// If we have a room, we'll join the first room we see.
// If we are the user with the lowest user ID, we will create the room.
// Otherwise we will wait for the room to be created.
yield return new WaitForEndOfFrame();
if (roomManager.GetRoomCount() == 0)
{
if (ShouldLocalUserCreateRoom)
Expand Down
3 changes: 1 addition & 2 deletions Assets/HoloToolkit/Build/Editor/BuildDeployPortal.cs
Expand Up @@ -4,7 +4,6 @@
//

using UnityEngine;
using System.Collections;
using System.Net;
using System;
using System.IO;
Expand Down Expand Up @@ -419,7 +418,7 @@ public static bool DeviceLogFile_View(string packageFamilyName, ConnectInfo conn
// Open it up in default text editor
System.Diagnostics.Process.Start(logFile);
}
catch (System.Exception ex)
catch (Exception ex)
{
Debug.LogError(ex.ToString());
return false;
Expand Down
26 changes: 15 additions & 11 deletions Assets/HoloToolkit/Build/Editor/BuildDeployPrefs.cs
Expand Up @@ -9,7 +9,6 @@

namespace HoloToolkit.Unity
{

public static class BuildDeployPrefs
{
// Constants
Expand All @@ -28,45 +27,54 @@ public static string BuildDirectory
get { return GetEditorPref(EditorPrefs_BuildDir, "WindowsStoreApp"); }
set { EditorPrefs.SetString(EditorPrefs_BuildDir, value); }
}

public static string AbsoluteBuildDirectory
{
get { return Path.GetFullPath(Path.Combine(Path.Combine(Application.dataPath, ".."), BuildDirectory)); }
}

public static string MsBuildVersion
{
get { return GetEditorPref(EditorPrefs_MSBuildVer, BuildDeployTools.DefaultMSBuildVersion); }
set { EditorPrefs.SetString(EditorPrefs_MSBuildVer, value); }
}

public static string BuildConfig
{
get { return GetEditorPref(EditorPrefs_BuildConfig, "Debug"); }
set { EditorPrefs.SetString(EditorPrefs_BuildConfig, value); }
}

public static bool ForceRebuild
{
get { return GetEditorPref(EditorPrefs_ForceRebuild, false); }
set { EditorPrefs.SetBool(EditorPrefs_ForceRebuild, value); }
}

public static bool IncrementBuildVersion
{
get { return GetEditorPref(EditorPrefs_IncrementBuildVersion, true); }
set { EditorPrefs.SetBool(EditorPrefs_IncrementBuildVersion, value); }
}

public static string TargetIPs
{
get { return GetEditorPref(EditorPrefs_TargetIPs, "127.0.0.1"); }
set { EditorPrefs.SetString(EditorPrefs_TargetIPs, value); }
}

public static string DeviceUser
{
get { return GetEditorPref(EditorPrefs_DeviceUser, ""); }
set { EditorPrefs.SetString(EditorPrefs_DeviceUser, value); }
}

public static string DevicePassword
{
get { return GetEditorPref(EditorPrefs_DevicePwd, ""); }
set { EditorPrefs.SetString(EditorPrefs_DevicePwd, value); }
}

public static bool FullReinstall
{
get { return GetEditorPref(EditorPrefs_FullReinstall, true); }
Expand All @@ -79,11 +87,9 @@ private static string GetEditorPref(string key, string defaultValue)
{
return EditorPrefs.GetString(key);
}
else
{
EditorPrefs.SetString(key, defaultValue);
return defaultValue;
}

EditorPrefs.SetString(key, defaultValue);
return defaultValue;
}

private static bool GetEditorPref(string key, bool defaultValue)
Expand All @@ -92,11 +98,9 @@ private static bool GetEditorPref(string key, bool defaultValue)
{
return EditorPrefs.GetBool(key);
}
else
{
EditorPrefs.SetBool(key, defaultValue);
return defaultValue;
}

EditorPrefs.SetBool(key, defaultValue);
return defaultValue;
}
}
}

0 comments on commit 9d1fdc5

Please sign in to comment.