Skip to content

Instantly share code, notes, and snippets.

@the6th
Last active June 10, 2018 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the6th/f88a4b50150d419cf763880294967d03 to your computer and use it in GitHub Desktop.
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
// 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