コード例 #1
0
    private Vector3 _heading;          // Where the user looking.

    void Start()
    {
        MLEyes.Start();                                                              // Start eye tracking.
        MLInput.Start();                                                             // Start input controller.
        MLInput.OnTriggerDown += HandleOnTriggerDown;                                // Get trigger down event.

        meshRenderer = gameObject.GetComponent <MeshRenderer>();                     // Get the game object.

        PNConfiguration pnConfiguration = new PNConfiguration();                     // Start PubNub

        pnConfiguration.PublishKey   = "pub-c-bb13912e-7007-46ce-a954-74fe4c6cb131"; // YOUR PUBLISH KEY HERE.
        pnConfiguration.SubscribeKey = "sub-c-e14cda48-b857-11e8-b27d-1678d61e8f93"; // YOUR SUBSCRIBE KEY HERE.
        pubnub  = new PubNub(pnConfiguration);
        pn_uuid = pnConfiguration.UUID;                                              // Get the UUID of the PubNub client.

        pubnub.Subscribe()
        .Channels(new List <string>()
        {
            meshRenderer.name     // Subscribe to the channel for the game object.
        })
        .Execute();
        pubnub.SusbcribeCallback += (sender, e) => {
            SusbcribeEventEventArgs message = e as SusbcribeEventEventArgs;
            if (message.Status != null)
            {
                switch (message.Status.Category)
                {
                case PNStatusCategory.PNUnexpectedDisconnectCategory:
                case PNStatusCategory.PNTimeoutCategory:
                    pubnub.Reconnect();
                    break;
                }
            }
            if (message.MessageResult != null)
            {
                // Does the message equal the UUID for this client?
                if (message.MessageResult.Payload.ToString() == pn_uuid) // Message and client UUID are the same.
                {
                    meshRenderer.material = OwnedMaterial;               // The user owns the game object, change material to OwnedMaterial to show.
                    looking = false;
                    owned   = true;
                }
                else                                                // Message and client UUID are NOT the same.
                {
                    if (owned)                                      // Only need to change color if the user owns the game object.
                    {
                        meshRenderer.material = NonFocusedMaterial; // Another user has taken the game object, change material to NonFocusedMaterial to show..
                        owned = false;
                    }
                }
            }
        };
    }
コード例 #2
0
ファイル: Example.cs プロジェクト: SaketSaumya/ARCHATv5
 void ButtonReconnectHandler()
 {
     Debug.Log("in ButtonReconnect");
     pubnub.Reconnect();
 }