Has anyone tried the Photon Unity Networking plugin? Any luck in getting it to work with HoloLens? If yes then how did you do it?
Just download PUN and try the very first sample... it just works.
- Import Photon Unity Networking
- Register App Id
- File > Build Settings > Scenes In Build
Uncheck all scenes but "DemoBoxes" - Open scene "DemoBoxes"
- Add "Box Colider" Component to all "Scripted Plane" in "Scripted Planes" to catch gaze
- Import MRTK
- Configure > Apply Mixed Reality Project Settings
- Configure > Apply Mixed Reality Scene Settings
- Configure > Apply UWP Capablity Settings
Check "Internet Client" - Add three parts to "OnClickInstantiate.cs" in "Scripted Plane" as below:
using UnityEngine; using System.Collections; using HoloToolkit.Unity.InputModule; // Added 1 public class OnClickInstantiate : MonoBehaviour, IInputClickHandler // Added 2 { public GameObject Prefab; public int InstantiateType; private string[] InstantiateTypeNames = {"Mine", "Scene"}; public bool showGui; void OnClick() { if (!PhotonNetwork.inRoom) { // only use PhotonNetwork.Instantiate while in a room. return; } switch (InstantiateType) { case 0: PhotonNetwork.Instantiate(Prefab.name, InputToEvent.inputHitPos + new Vector3(0, 5f, 0), Quaternion.identity, 0); break; case 1: PhotonNetwork.InstantiateSceneObject(Prefab.name, InputToEvent.inputHitPos + new Vector3(0, 5f, 0), Quaternion.identity, 0, null); break; } } void OnGUI() { if (showGui) { GUILayout.BeginArea(new Rect(Screen.width - 180, 0, 180, 50)); InstantiateType = GUILayout.Toolbar(InstantiateType, InstantiateTypeNames); GUILayout.EndArea(); } } public void OnInputClicked(InputClickedEventData eventData) // Added 3 { OnClick(); Debug.Log("Airtapped"); } }
Done!