コード例 #1
0
 void Start()
 {
     UnityMCSessionNativeInterface.GetMcSessionNativeInterface()
     .WorldMapReceivedAsObservable()
     .Subscribe(RestartARSessionWith)
     .AddTo(this);
 }
コード例 #2
0
 void Start()
 {
     UnityMCSessionNativeInterface.GetMcSessionNativeInterface()
     .DataReceivedAsObservable()
     .Subscribe(Received)
     .AddTo(this);
 }
コード例 #3
0
    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);
    }
コード例 #4
0
    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);
 }
コード例 #6
0
        public NetworkManageriOS(ARSession arSession)
        {
            // todo: clean these up
            UnityMCSessionNativeInterface.GetMcSessionNativeInterface().DataReceivedEvent += OnDataReceivedEvent;
            UnityMCSessionNativeInterface.GetMcSessionNativeInterface().StateChangedEvent += OnStateChangedEvent;

            _arSession = arSession;
        }
コード例 #7
0
 void Start()
 {
     sendWorldMapButton.OnClickAsObservable()
     .Select(_ => GetARWorldMapAsync().ToObservable())
     .Switch()
     .Select(x => (PackableARWorldMap)x)
     .Subscribe(UnityMCSessionNativeInterface.GetMcSessionNativeInterface().SendToAllPeers)
     .AddTo(this);
 }
コード例 #8
0
    static async UniTask SendCurrentARWorldMapToAllPeersAsync()
    {
        var arSessionNativeInterface = UnityARSessionNativeInterface.GetARSessionNativeInterface();
        var arWorldMap = await arSessionNativeInterface.GetCurrentWorldMapAsnyc();

        var nativePtr = arWorldMap.nativePtr;
        var mcSessionNativeInterface = UnityMCSessionNativeInterface.GetMcSessionNativeInterface();

        mcSessionNativeInterface.SendToAllPeers(nativePtr);
    }
コード例 #9
0
        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);
        }
コード例 #11
0
 static IObservable <UnityARUserAnchorData> AnchorReceivedAsObservable()
 {
     return(UnityMCSessionNativeInterface.GetMcSessionNativeInterface()
            .DataReceivedAsObservable <PackableARUserAnchor>()
            .Select(x => (UnityARUserAnchorData)x));
 }
コード例 #12
0
 static IObservable <UnityARUserAnchorData> AnchorReceivedAsObservable()
 {
     return(UnityMCSessionNativeInterface.GetMcSessionNativeInterface()
            .AnchorReceivedAsObservable());
 }
コード例 #13
0
 protected override void SendMessage(NetworkMessageStruct message)
 {
     Debug.Log("Send message to all friends");
     UnityMCSessionNativeInterface.GetMcSessionNativeInterface().SendToAllPeers(message.Serialize());
 }
コード例 #14
0
 static void SendAnchorToAllPeers(UnityARUserAnchorData anchorData)
 {
     UnityMCSessionNativeInterface.GetMcSessionNativeInterface()
     .SendToAllPeers(anchorData);
 }
コード例 #15
0
 public void SendData(string data)
 {
     Debug.Log("Sent: " + data);
     UnityMCSessionNativeInterface.GetMcSessionNativeInterface()
     .SendToAllPeers(SystemInfo.deviceName + "," + data);
 }