void Start() { UnityMCSessionNativeInterface.GetMcSessionNativeInterface() .WorldMapReceivedAsObservable() .Subscribe(RestartARSessionWith) .AddTo(this); }
void Start() { UnityMCSessionNativeInterface.GetMcSessionNativeInterface() .DataReceivedAsObservable() .Subscribe(Received) .AddTo(this); }
void Start() { var mcSession = UnityMCSessionNativeInterface.GetMcSessionNativeInterface(); var connectingPeers = new ReactiveCollection <string>(); mcSession.StateChangedAsObservable() .Subscribe(t => { switch (t.Item2) { case UnityMCSessionState.Connecting: break; case UnityMCSessionState.Connected: connectingPeers.Add(t.Item1.DisplayName); break; case UnityMCSessionState.NotConnected: connectingPeers.Remove(t.Item1.DisplayName); break; } }) .AddTo(this); connectingPeers.ObserveAdd() .AsUnitObservable() .Merge(connectingPeers.ObserveRemove().AsUnitObservable()) .Select(_ => connectingPeers) .Subscribe(Refresh) .AddTo(this); }
static async UniTask SendCurrentARWorldMapToAllPeersAsync() { var arSessionNativeInterface = UnityARSessionNativeInterface.GetARSessionNativeInterface(); var arWorldMap = await arSessionNativeInterface.GetCurrentWorldMapAsnyc(); UnityMCSessionNativeInterface.GetMcSessionNativeInterface().SendToAllPeers((PackableARWorldMap)arWorldMap); }
void Start() { UnityMCSessionNativeInterface.GetMcSessionNativeInterface() .DataReceivedAsObservable <PackableARWorldMap>() .Select(x => (ARWorldMap)x) .Subscribe(ApplyWorldMap) .AddTo(this); }
public NetworkManageriOS(ARSession arSession) { // todo: clean these up UnityMCSessionNativeInterface.GetMcSessionNativeInterface().DataReceivedEvent += OnDataReceivedEvent; UnityMCSessionNativeInterface.GetMcSessionNativeInterface().StateChangedEvent += OnStateChangedEvent; _arSession = arSession; }
void Start() { sendWorldMapButton.OnClickAsObservable() .Select(_ => GetARWorldMapAsync().ToObservable()) .Switch() .Select(x => (PackableARWorldMap)x) .Subscribe(UnityMCSessionNativeInterface.GetMcSessionNativeInterface().SendToAllPeers) .AddTo(this); }
static async UniTask SendCurrentARWorldMapToAllPeersAsync() { var arSessionNativeInterface = UnityARSessionNativeInterface.GetARSessionNativeInterface(); var arWorldMap = await arSessionNativeInterface.GetCurrentWorldMapAsnyc(); var nativePtr = arWorldMap.nativePtr; var mcSessionNativeInterface = UnityMCSessionNativeInterface.GetMcSessionNativeInterface(); mcSessionNativeInterface.SendToAllPeers(nativePtr); }
void Start() { if (!ARKitSessionSubsystem.supportsCollaboration) { return; } if (arSession == null) { return; } if (!(arSession.subsystem is ARKitSessionSubsystem arKitSessionSubsystem)) { throw new Exception("No session subsystem available. Could not load."); } arKitSessionSubsystem.collaborationEnabled = true; var mcSession = UnityMCSessionNativeInterface.GetMcSessionNativeInterface(); SendCollaborationDataAsync(arKitSessionSubsystem, mcSession, this.GetCancellationTokenOnDestroy()).Forget(); }
void Start() { if (!ARKitSessionSubsystem.supportsCollaboration) { return; } if (arSession == null) { return; } if (!(arSession.subsystem is ARKitSessionSubsystem arKitSessionSubsystem)) { throw new Exception("No session subsystem available. Could not load."); } arKitSessionSubsystem.collaborationEnabled = true; void OnReceive(PackableARCollaborationData data) { var collaborationData = (ARCollaborationData)data; if (!collaborationData.valid) { return; } arKitSessionSubsystem.UpdateWithCollaborationData(collaborationData); } var mcSession = UnityMCSessionNativeInterface.GetMcSessionNativeInterface(); mcSession.DataReceivedAsObservable <PackableARCollaborationData>() .Subscribe(OnReceive) .AddTo(this); }
static IObservable <UnityARUserAnchorData> AnchorReceivedAsObservable() { return(UnityMCSessionNativeInterface.GetMcSessionNativeInterface() .DataReceivedAsObservable <PackableARUserAnchor>() .Select(x => (UnityARUserAnchorData)x)); }
static IObservable <UnityARUserAnchorData> AnchorReceivedAsObservable() { return(UnityMCSessionNativeInterface.GetMcSessionNativeInterface() .AnchorReceivedAsObservable()); }
protected override void SendMessage(NetworkMessageStruct message) { Debug.Log("Send message to all friends"); UnityMCSessionNativeInterface.GetMcSessionNativeInterface().SendToAllPeers(message.Serialize()); }
static void SendAnchorToAllPeers(UnityARUserAnchorData anchorData) { UnityMCSessionNativeInterface.GetMcSessionNativeInterface() .SendToAllPeers(anchorData); }
public void SendData(string data) { Debug.Log("Sent: " + data); UnityMCSessionNativeInterface.GetMcSessionNativeInterface() .SendToAllPeers(SystemInfo.deviceName + "," + data); }