Last active
June 10, 2018 02:11
-
-
Save the6th/f88a4b50150d419cf763880294967d03 to your computer and use it in GitHub Desktop.
Create enhanced 3D visuals with Holographic Remoting in UWP http://littlewing.hatenablog.com/entry/2018/06/09/212947
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Unity 2018.2.b7 | |
// | |
// Create enhanced 3D visuals with Holographic Remoting in UWP: | |
// https://blogs.unity3d.com/jp/2018/05/30/create-enhanced-3d-visuals-with-holographic-emulation-in-uwp/ | |
// | |
// my blog: | |
// http://littlewing.hatenablog.com/entry/2018/06/09/212947 | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.XR; | |
using UnityEngine.XR.WSA; | |
public class RemotingExample : MonoBehaviour | |
{ | |
[SerializeField] | |
private string IP; | |
private bool connected = false; | |
public void Connect() | |
{ | |
if (HolographicRemoting.ConnectionState != HolographicStreamerConnectionState.Connected) | |
{ | |
HolographicRemoting.Connect(IP); | |
} | |
} | |
void Update() | |
{ | |
if (!connected && HolographicRemoting.ConnectionState == HolographicStreamerConnectionState.Connected) | |
{ | |
connected = true; | |
StartCoroutine(LoadDevice("WindowsMR")); | |
} | |
} | |
IEnumerator LoadDevice(string newDevice) | |
{ | |
XRSettings.LoadDeviceByName(newDevice); | |
yield return null; | |
XRSettings.enabled = true; | |
} | |
private void OnGUI() | |
{ | |
IP = GUI.TextField(new Rect(10, 10, 200, 30), IP, 25); | |
string button = (connected ? "Disconnect" : "Connect"); | |
if (GUI.Button(new Rect(220, 10, 100, 30), button)) | |
{ | |
if (connected) | |
{ | |
HolographicRemoting.Disconnect(); | |
connected = false; | |
} | |
else | |
Connect(); | |
Debug.Log(button); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment