コード例 #1
0
        private void _UpdateCloudAnchorRequest(CloudAnchorRequest request, bool isNewRequest = false)
        {
            var cloudState = request.NativeSession.AnchorApi.GetCloudAnchorState(request.AnchorHandle);

            if (cloudState == ApiCloudAnchorState.Success)
            {
                var result = new CloudAnchorResult()
                {
                    Response = CloudServiceResponse.Success,
                    Anchor   = XPAnchor.Factory(request.NativeSession, request.AnchorHandle)
                };

                request.OnTaskComplete(result);
                request.IsComplete = true;
            }
            else if (cloudState != ApiCloudAnchorState.TaskInProgress)
            {
                request.NativeSession.AnchorApi.Detach(request.AnchorHandle);
                request.NativeSession.AnchorApi.Release(request.AnchorHandle);

                var result = new CloudAnchorResult()
                {
                    Response = cloudState.ToCloudServiceResponse(),
                    Anchor   = null
                };

                request.OnTaskComplete(result);
                request.IsComplete = true;
            }
            else if (isNewRequest)
            {
                m_CloudAnchorRequests.Add(request);
            }
        }
コード例 #2
0
    public void RestoreAnchorsButtonClicked()
    {
        mLogger.CategoryLog(LogCategoryMethodIn);
        int    anchorCount = CloudAnchorManager.Count;
        string anchorId    = null;

        mCloudAnchorDic.Clear();
        for (int i = 0; i < anchorCount; i++)
        {
            if (CloudAnchorManager.GetCloudAnchorId(i, out anchorId))
            {
                XPSession.ResolveCloudAnchor(anchorId).ThenAction(
                    delegate(CloudAnchorResult result)
                {
                    XPAnchor xpAnchor = result.Anchor;
                    if (xpAnchor != null)
                    {
                        AddAnchorGO(xpAnchor);
                    }
                }
                    );
            }
        }
        mLogger.CategoryLog(LogCategoryMethodOut);
    }
        // -------------------------------------------

        /*
         * Connects with a cloud anchor id from Google Platform
         */
        private void ResolveAnchorFromId(string _cloudAnchorId)
        {
            m_enableSetUpAnchor = false;
            if (ENABLE_ARCORE_CLOUD_SHARED)
            {
                XPSession.ResolveCloudAnchor(_cloudAnchorId).ThenAction((System.Action <CloudAnchorResult>)(result =>
                {
                    if (result.Response != CloudServiceResponse.Success)
                    {
                        BasicSystemEventController.Instance.DispatchBasicSystemEvent(EVENT_CLOUDGAMEANCHOR_SETUP_ANCHOR, false);
                        return;
                    }

                    if (!m_hasBeenInitialized)
                    {
                        m_hasBeenInitialized = true;
                        m_lastResolvedAnchor = result.Anchor;
                        PlaceCubeReferenceAnchor(m_lastResolvedAnchor.transform.position, m_lastResolvedAnchor.transform);
                    }
                }));
            }
            else
            {
                m_hasBeenInitialized = true;
            }
        }
コード例 #4
0
        /// <summary>
        /// Resets the internal status and UI.
        /// </summary>
        private void _ResetStatus()
        {
            // Reset internal status.
            m_CurrentMode = ApplicationMode.Ready;

            //if there exists an anchor placed
            if (m_LastPlacedAnchor != null)
            {
                Destroy(m_LastPlacedAnchor.gameObject);
            }

            m_LastPlacedAnchor = null;

            //if there exists an anchor that is resolved
            if (m_LastResolvedAnchor != null)
            {
                //destroy the anchor resolved
                Destroy(m_LastResolvedAnchor.gameObject);
            }

            m_LastResolvedAnchor = null;

            //if there isnt an anchor placed or an anchor resolved
            //this function will always be called
            UIController.ShowReadyMode();
        }
コード例 #5
0
        /// <summary>
        /// Resolves an anchor id and instantiates an Andy prefab on it.
        /// </summary>
        /// <param name="cloudAnchorId">Cloud anchor id to be resolved.</param>
        private void _ResolveAnchorFromId(string cloudAnchorId)
        {
            XPSession.ResolveCloudAnchor(cloudAnchorId).ThenAction((System.Action <CloudAnchorResult>)(result =>
            {
                if (result.Response != CloudServiceResponse.Success)
                {
                    UIController.ShowResolvingModeBegin(string.Format("Resolving Error: {0}.", result.Response));
                    return;
                }

                if (mainControllerScript.OperationTheater != null)
                {
                    mainControllerScript.OperationTheater.SetActive(true);
                }
                m_LastResolvedAnchor = result.Anchor;
                // Instantiate(_GetAndyPrefab(), result.Anchor.transform);

                if (mainControllerScript.OperationTheater != null)
                {
                    mainControllerScript.placeOR(m_LastResolvedAnchor.transform);
                }

                UIController.ShowResolvingModeSuccess();
            }));
        }
コード例 #6
0
        private void UpdateCloudAnchorRequest(
            CloudAnchorRequest request, bool isNewRequest = false)
        {
            var cloudState =
                request.NativeSession.AnchorApi.GetCloudAnchorState(request.AnchorHandle);

            if (cloudState == ApiCloudAnchorState.Success)
            {
                XPAnchor             xpAnchor = null;
                CloudServiceResponse response = CloudServiceResponse.Success;
                try
                {
                    xpAnchor = XPAnchor.Factory(request.NativeSession, request.AnchorHandle);
                }
                catch (Exception e)
                {
                    Debug.LogError("Failed to create XP Anchor: " + e.Message);
                    response = CloudServiceResponse.ErrorInternal;
                }

                var result = new CloudAnchorResult()
                {
                    Response = response,
                    Anchor   = xpAnchor,
                };

                request.OnTaskComplete(result);
                request.IsComplete = true;
            }
            else if (cloudState != ApiCloudAnchorState.TaskInProgress)
            {
                if (request.NativeSession != null && !request.NativeSession.IsDestroyed)
                {
                    request.NativeSession.AnchorApi.Detach(request.AnchorHandle);
                }

                AnchorApi.Release(request.AnchorHandle);

                var result = new CloudAnchorResult()
                {
                    Response = cloudState.ToCloudServiceResponse(),
                    Anchor   = null
                };

                request.OnTaskComplete(result);
                request.IsComplete = true;
            }
            else if (isNewRequest)
            {
                _cloudAnchorRequests.Add(request);
            }
        }
コード例 #7
0
        // client -- color and ui
        private void _ResolveAnchorFromId(string cloudAnchorId)
        {
            XPSession.ResolveCloudAnchor(cloudAnchorId).ThenAction((System.Action <CloudAnchorResult>)(result =>
            {
                if (result.Response != CloudServiceResponse.Success)
                {
                    UIController.Instance.ShowResolvingModeBegin(string.Format("Resolving Error: {0}.", result.Response));
                    return;
                }

                m_LastResolvedAnchor = result.Anchor;
                UIController.Instance.ShowResolvingModeSuccess();
            }));
        }
        // -------------------------------------------

        /*
         * ResetStatus
         */
        private void ResetStatus()
        {
            // Reset internal status.
            if (m_lastPlacedAnchor != null)
            {
                Destroy(m_lastPlacedAnchor);
            }
            m_lastPlacedAnchor = null;

            if (m_lastPlacedAnchor != null)
            {
                Destroy(m_lastResolvedAnchor);
            }
            m_lastResolvedAnchor = null;
        }
コード例 #9
0
 /// <summary>
 /// Resets the internal status and UI.
 /// </summary>
 private void _ResetStatus()
 {
     // Reset internal status.
     m_CurrentMode = ApplicationMode.Ready;
     if (m_LastPlacedAnchor != null)
     {
         Destroy(m_LastPlacedAnchor.gameObject);
     }
     m_LastPlacedAnchor = null;
     if (m_LastResolvedAnchor != null)
     {
         Destroy(m_LastResolvedAnchor.gameObject);
     }
     m_LastResolvedAnchor = null;
     UIController.ShowReadyMode();
 }
コード例 #10
0
        /// <summary>
        /// Resolves an anchor id and instantiates an Andy prefab on it.
        /// </summary>
        /// <param name="cloudAnchorId">Cloud anchor id to be resolved.</param>
        private void _ResolveAnchorFromId(string cloudAnchorId)
        {
            XPSession.ResolveCloudAnchor(cloudAnchorId).ThenAction((System.Action <CloudAnchorResult>)(result =>
            {
                if (result.Response != CloudServiceResponse.Success)
                {
                    UIController.ShowResolvingModeBegin(string.Format("Resolving Error: {0}.", result.Response));
                    return;
                }

                m_LastResolvedAnchor = result.Anchor;
                andyObjectInsta      = Instantiate(_GetAndyPrefab(), result.Anchor.transform);
                andyObjectInsta.transform.Rotate(k_ModelRotation, 0, 0, Space.Self);
                UIController.ShowResolvingModeSuccess();
            }));
        }
コード例 #11
0
        /// <summary>
        /// Resets the internal status and UI.
        /// </summary>
        private void _ResetStatus()
        {
            // Reset internal status.
            if (m_LastPlacedAnchor != null)
            {
                Destroy(m_LastPlacedAnchor.gameObject);
            }

            m_LastPlacedAnchor = null;
            if (m_LastResolvedAnchor != null)
            {
                Destroy(m_LastResolvedAnchor.gameObject);
            }

            m_LastResolvedAnchor = null;
        }
コード例 #12
0
    /// <summary>
    /// Resets the internal status and UI.
    /// </summary>
    protected void _ResetStatus()
    {
        m_CurrentMode = ApplicationMode.Ready;
        if (m_LastPlacedAnchor != null)
        {
            Destroy(m_LastPlacedAnchor.gameObject);
        }

        m_LastPlacedAnchor = null;
        if (m_LastResolvedAnchor != null)
        {
            Destroy(m_LastResolvedAnchor.gameObject);
        }

        m_LastResolvedAnchor = null;
    }
コード例 #13
0
        /// <summary>
        /// Handles the user intent to resolve the cloud anchor associated with a room they have typed into the UI.
        /// </summary>
        public void ResolveAnchor(string ip, int room, System.Action <Transform> resolvedAnchorHandler, System.Action <CloudServiceResponse> failResolveAnchorHandle)
        {
            if (m_CurrentMode == ApplicationMode.Resolving)
            {
                return;
            }
            m_CurrentMode = ApplicationMode.Resolving;

            if (room <= 0)
            {
                Luwu.Logger.Error("invalid room...");
                return;
            }

            RoomSharingClient roomSharingClient = new RoomSharingClient();

            roomSharingClient.GetAnchorIdFromRoom(room, ip, (bool found, string cloudAnchorId) =>
            {
                if (!found)
                {
                    Luwu.Logger.Error("Anchor resolve failed due to invalid room code, " +
                                      "ip address or network error.");
                }
                else
                {
                    XPSession.ResolveCloudAnchor(cloudAnchorId).ThenAction((System.Action <CloudAnchorResult>)(result =>
                    {
                        if (result.Response != CloudServiceResponse.Success)
                        {
                            if (failResolveAnchorHandle != null)
                            {
                                failResolveAnchorHandle(result.Response);
                            }
                            Luwu.Logger.Error(string.Format("Resolving Error: {0}.", result.Response));
                            return;
                        }

                        m_LastResolvedAnchor = result.Anchor;
                        if (resolvedAnchorHandler != null)
                        {
                            resolvedAnchorHandler(m_LastResolvedAnchor.transform);
                        }
                        Luwu.Logger.Info("Resolved Anchor success...");
                    }));
                }
            });
        }
コード例 #14
0
    public void ListCloudAnchorButtonClicked()
    {
        mLogger.CategoryLog(LogCategoryMethodIn);
        mListCloudAnchorPanelGO.SetActive(true);

        GameObject cloudAnchorListContentGO = mListCloudAnchorPanelGO.transform.Find("CloudAnchorList/Viewport/Content").gameObject;

        // 一旦子要素を全て解放
        string cloudAnchorId = null;

        for (int i = 0, size = cloudAnchorListContentGO.transform.childCount; i < size; i++)
        {
            GameObject childGO = cloudAnchorListContentGO.transform.GetChild(i).gameObject;
            Destroy(childGO);
        }
        cloudAnchorListContentGO.transform.DetachChildren();

        int cloudAnchorCount = CloudAnchorManager.Count;

        // Scroll Viewの設定
        float itemHeight        = mListItemPrefab.GetComponent <LayoutElement>().preferredHeight;
        float itemVerticalSpace = cloudAnchorListContentGO.GetComponent <VerticalLayoutGroup>().spacing;

        cloudAnchorListContentGO.GetComponent <RectTransform>().sizeDelta = new Vector2(0, (itemHeight + itemVerticalSpace) * cloudAnchorCount);

        for (int i = 0, size = CloudAnchorManager.Count; i < size; i++)
        {
            if (CloudAnchorManager.GetCloudAnchorId(i, out cloudAnchorId))
            {
                XPSession.ResolveCloudAnchor(cloudAnchorId).ThenAction((CloudAnchorResult result) =>
                {
                    XPAnchor xpAnchor = result.Anchor;

                    if (xpAnchor != null)
                    {
                        // リストに追加
                        GameObject listItemGO = Instantiate(mListItemPrefab);
                        //listItemGO.transform.Find("CloudAnchorId").gameObject.GetComponent<UnityEngine.UI.Text>().text = xpAnchor.CloudId;
                        mLogger.CategoryLog(LogCategoryMethodTrace, "cloud anchor id = " + xpAnchor.CloudId);
                        listItemGO.GetComponent <UnityEngine.UI.Text>().text = xpAnchor.CloudId;
                        listItemGO.transform.SetParent(cloudAnchorListContentGO.transform);
                    }
                });
            }
        }
        mLogger.CategoryLog(LogCategoryMethodOut);
    }
コード例 #15
0
        /// <summary>
        /// Resets the internal status and UI.
        /// </summary>
        private void _ResetStatus()
        {
            // Reset internal status.
            m_CurrentMode = ApplicationMode.Ready;
            if (m_LastPlacedAnchor != null)
            {
                Destroy(m_LastPlacedAnchor.gameObject);
            }

            m_LastPlacedAnchor = null;
            if (m_LastResolvedAnchor != null)
            {
                Destroy(m_LastResolvedAnchor.gameObject);
            }

            m_LastResolvedAnchor = null;
            UIManager.Instance().ResetMatchmakingUI();
        }
コード例 #16
0
        /// <summary>
        /// Resets the internal status and UI.
        /// </summary>
        private void _ResetStatus()
        {
            // Reset internal status.
            m_CurrentMode = ApplicationMode.Ready;
            if (m_LastPlacedAnchor != null)
            {
                Destroy(m_LastPlacedAnchor.gameObject);
            }

            m_LastPlacedAnchor = null;
            if (m_LastResolvedAnchor != null)
            {
                Destroy(m_LastResolvedAnchor.gameObject);
            }

            m_LastResolvedAnchor = null;
            Luwu.Logger.Info("Ready..");
        }
コード例 #17
0
        /// <summary>
        /// Resolves an anchor id and instantiates an Andy prefab on it.
        /// </summary>
        /// <param name="cloudAnchorId">Cloud anchor id to be resolved.</param>
        private void _ResolveAnchorFromId(int roomToResolve, string cloudAnchorId)
        {
            XPSession.ResolveCloudAnchor(cloudAnchorId).ThenAction((System.Action <CloudAnchorResult>)(result =>
            {
                if (result.Response != CloudServiceResponse.Success)
                {
                    UIManager.Instance().ShowResolvingModeBegin(string.Format("Resolving Error: {0}.", result.Response));
                    return;
                }

                m_LastResolvedAnchor = result.Anchor;
                Instantiate(_GetAndyPrefab(), result.Anchor.transform);
                UIManager.Instance().ShowResolvingModeSuccess();

                GameManager.Instance().matchGroup      = roomToResolve.ToString();
                GameManager.Instance().anchorTransform = result.Anchor.transform;
                GameManager.Instance().isConnected     = true;
            }));
        }
コード例 #18
0
        /// <summary>
        /// Resolves an anchor id and instantiates an Andy prefab on it.
        /// </summary>
        /// <param name="cloudAnchorId">Cloud anchor id to be resolved.</param>
        private void _ResolveAnchorFromId(string cloudAnchorId)
        {
            XPSession.ResolveCloudAnchor(cloudAnchorId).ThenAction((System.Action <CloudAnchorResult>)(result =>
            {
                if (result.Response != CloudServiceResponse.Success)
                {
                    UIController.ShowResolvingModeBegin(string.Format("Resolving Error: {0}.", result.Response));
                    return;
                }
                GameObject prefab = _GetAndyPrefab();

                m_LastResolvedAnchor = result.Anchor;

                Instantiate(prefab, result.Anchor.transform);
                //prefab.GetComponent<TreeScript>().updateScale(treeScale);
                //prefab.transform.localScale = scale;
                UIController.ShowResolvingModeSuccess();
            }));
        }
コード例 #19
0
    private void AddAnchorGO(XPAnchor xpAnchor, GameObject anchorGO = null, Anchor anchor = null)
    {
        mLogger.CategoryLog(LogCategoryMethodIn);

        if (anchorGO != null || !mCloudAnchorGODic.TryGetValue(xpAnchor.CloudId, out anchorGO))
        {
            if (anchorGO == null)
            {
                anchorGO = Instantiate(mAnchorPrefab, xpAnchor.transform.position, xpAnchor.transform.rotation);
            }
            anchorGO.SetActive(true);

            mAnchorDic[xpAnchor.CloudId]        = anchor;
            mCloudAnchorDic[xpAnchor.CloudId]   = xpAnchor;
            mCloudAnchorGODic[xpAnchor.CloudId] = anchorGO;
            CloudAnchorManager.Append(xpAnchor.CloudId);
        }
        mLogger.CategoryLog(LogCategoryMethodOut);
    }
コード例 #20
0
    public void AddPanelCloudAnchorButtonClicked()
    {
        mLogger.CategoryLog(LogCategoryMethodIn);
        mAddCloudAnchorPanelGO.SetActive(false);

        string inputAnchorId = mIfCloudAnchorId.text;

        if (!string.IsNullOrEmpty(inputAnchorId))
        {
            XPSession.ResolveCloudAnchor(inputAnchorId).ThenAction((CloudAnchorResult result) =>
            {
                XPAnchor xpAnchor = result.Anchor;
                if (xpAnchor != null)
                {
                    AddAnchorGO(xpAnchor);
                }
            });
        }
        mLogger.CategoryLog(LogCategoryMethodOut);
    }
コード例 #21
0
        /// <summary>
        /// Resets the internal status and UI.
        /// </summary>
        private void _ResetStatus()
        {
            // if(mainControllerScript.OperationTheater != null){
            //     mainControllerScript.transform.SetParent(null);
            //     mainControllerScript.OperationTheater.SetActive(false);
            // }
            // Reset internal status.
            m_CurrentMode = ApplicationMode.Ready;
            if (m_LastPlacedAnchor != null)
            {
                mainControllerScript.deactivateOR();
            }
            m_LastPlacedAnchor = null;

            if (m_LastResolvedAnchor != null)
            {
                mainControllerScript.deactivateOR();
            }
            m_LastResolvedAnchor = null;
            UIController.ShowReadyMode();
        }
コード例 #22
0
        /// <summary>
        /// Resets the internal status and UI.
        /// </summary>
        private void _ResetStatus()
        {
            // Reset internal status.
            m_CurrentMode = ApplicationMode.Ready;

            if (m_LastPlacedAnchor != null)
            {
                Destroy(m_LastPlacedAnchor.gameObject);
            }

            m_LastPlacedAnchor = null;
            if (m_LastResolvedAnchor != null)
            {
                Destroy(m_LastResolvedAnchor.gameObject);
            }

            m_LastResolvedAnchor = null;

            // NetworkServer.Reset();
            // NetworkServer.ResetConnectionStats();

            UIController.Instance.ShowLobbyUI();
        }
コード例 #23
0
    internal override void Update()
    {
        base.Update();

        if (Session.Status != SessionStatus.Tracking)
        {
            return;
        }

        if ((mListCloudAnchorPanelGO.activeInHierarchy == false) && (mAddCloudAnchorPanelGO.activeInHierarchy == false))
        {
            Touch lastTouched;
            if (LastTouch(out lastTouched))
            {
                if (lastTouched.phase == TouchPhase.Ended)
                {
                    TrackableHit hit;
                    if (Frame.Raycast(lastTouched.position.x, lastTouched.position.y, TrackableHitFlags.PlaneWithinPolygon | TrackableHitFlags.FeaturePointWithSurfaceNormal, out hit))
                    {
                        // Anchorを生成
                        Anchor anchor = Session.CreateAnchor(hit.Pose, hit.Trackable);

                        GameObject anchorGO = Instantiate(mAnchorPrefab, anchor.transform.position, anchor.transform.rotation);
                        anchorGO.SetActive(true);
                        anchorGO.transform.parent = anchor.transform;

                        // CloudAnchorを生成
                        XPSession.CreateCloudAnchor(anchor).ThenAction(delegate(CloudAnchorResult result)
                        {
                            XPAnchor xpAnchor = result.Anchor;

                            if (xpAnchor != null)
                            {
                                AddAnchorGO(xpAnchor, anchorGO, anchor);
                            }
                        });
                    }
                }
            }
        }

        // アニメーション
        bool enableAnimation = false;

        if (mLeftAnimationInterval > 0)
        {
            mLeftAnimationInterval    -= Time.deltaTime;
            mLeftOneAnimationInterval -= Time.deltaTime;

            if (mLeftOneAnimationInterval <= 0)
            {
                enableAnimation           = true;
                mLeftOneAnimationInterval = MinimumAnimationInterval;
            }
        }

        // 表示位置の更新
        if (mCloudAnchorDic.Count > 0)
        {
            foreach (string cloudAnchorId in mAnchorDic.Keys)
            {
                Anchor     anchor        = mAnchorDic[cloudAnchorId];
                GameObject cloudAnchorGO = null;

                if (enableAnimation)
                {
                    int    direction      = (mRandom.Next() * mRandom.Next()) % 3;
                    double distanceSource = mRandom.NextDouble() * mRandom.NextDouble();
                    float  distance       = ((float)(distanceSource - System.Math.Floor(distanceSource)) / 1);
                    if (direction == 0)
                    {
                        anchor.transform.position = new Vector3(anchor.transform.position.x + distance, anchor.transform.position.y, anchor.transform.position.z);
                    }
                    else if (direction == 1)
                    {
                        anchor.transform.position = new Vector3(anchor.transform.position.x, anchor.transform.position.y + distance, anchor.transform.position.z);
                    }
                    else
                    {
                        anchor.transform.position = new Vector3(anchor.transform.position.x, anchor.transform.position.y, anchor.transform.position.z + distance);
                    }
                }

                if ((enableAnimation || mUpdateAnchorsPosition) && mCloudAnchorGODic.TryGetValue(cloudAnchorId, out cloudAnchorGO))
                {
                    cloudAnchorGO.transform.SetPositionAndRotation(anchor.transform.position, anchor.transform.rotation);

                    mUpdateAnchorsPosition = false;
                }
            }
        }
    }
コード例 #24
0
 public CloudAnchor(XPAnchor _anchor, bool _worldOrigin)
 {
     anchor      = _anchor;
     worldOrigin = _worldOrigin;
 }
 /// <summary>
 /// Saves the cloud anchor to room.
 /// </summary>
 /// <param name="room">The room to save the anchor to.</param>
 /// <param name="anchor">The Anchor to save.</param>
 public void SaveCloudAnchorToRoom(int room, XPAnchor anchor)
 {
     m_RoomAnchorsDict.Add(room, anchor);
 }
コード例 #26
0
 public void SetResolvedAnchorInfo(XPAnchor anchor)
 {
     _resolvedAnchorInfo.Value = anchor;
 }
コード例 #27
0
ファイル: CubeController.cs プロジェクト: AkhilRaja/AR-Draw
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        //Not Server then Excecute
        if (!isServer)
        {
            //Code to Resolve the Anchor and Display resolved Anchor
            //Step - 1
            //Check if the cloudID is Null
            if (anchorID == "")
            {
                anchorID = CloudGuy.GetComponent <RetrieveCloudId>().cloudID;
            }
            //  message.text = "Inside Client Update : anchorId is : " + anchorID;
            //   anchorID = CloudGuy.GetComponent<RetrieveCloudId>().cloudID;

            if (anchorID != "" && clientAnchor == null)
            {
                message.text = "Resolving The Cloud Anchor .." + anchorID;

                XPSession.ResolveCloudAnchor(anchorID).ThenAction((System.Action <CloudAnchorResult>)(result =>
                {
                    if (result.Response != CloudServiceResponse.Success)
                    {
                        message.text = "Error Resolving the Client" + result.Response;
                        return;
                    }

                    message.text = "SuccessFully Resolved";
                    clientAnchor = result.Anchor;
                    clientAnchor.transform.rotation = transform.rotation;
                    this.transform.parent           = clientAnchor.transform;
                }));
            }



            if (Input.GetButtonDown("Fire1"))
            {
                CmdSetInputButtonDown(true);
                check1 = true;
            }
            else
            {
                if (check1)
                {
                    CmdSetInputButtonDown(false);
                }

                check1 = false;
            }

            if (Input.GetButton("Fire1"))
            {
                CmdSetInputButton(true);
                check2 = true;
            }
            else
            {
                if (check2)
                {
                    CmdSetInputButton(false);
                }

                check2 = false;
            }

            if (Input.GetButtonUp("Fire1"))
            {
                CmdSetInputButtonUp(true);
                check3 = true;
            }
            else
            {
                if (check3)
                {
                    CmdSetInputButtonUp(false);
                }

                check3 = false;
            }
        }

        //Server Code
        else
        {
            time -= Time.deltaTime;
            if (mComponent == null && time <= 0)
            {
                message.text = "Creating Anchor";
                mComponent   = Session.CreateAnchor(Frame.Pose);

                if (mComponent != null)
                {
                    this.transform.parent = mComponent.transform;

                    var anchor = (Anchor)mComponent;
                    XPSession.CreateCloudAnchor(anchor).ThenAction(result =>
                    {
                        if (result.Response != CloudServiceResponse.Success)
                        {
                            message.text = "Failed" + result.Response;
                            return;
                        }

                        message.text = "Hosted it Successfully" + result.Anchor.CloudId;
                        anchorID     = result.Anchor.CloudId;
                        RpcSetCloudid(anchorID);
                    });
                }
            }
            else if (time > 1)
            {
                message.text = "Walk Around and Wait for Time : " + time;
            }


            if (Input.GetButtonDown("Fire1"))
            {
                RpcSetInputButtonDown(true);
            }
            else
            {
                RpcSetInputButtonDown(false);
            }
            if (Input.GetButton("Fire1"))
            {
                check2 = true;
                RpcSetInputButton(true);
            }
            else
            {
                if (check2)
                {
                    RpcSetInputButton(false);
                }
                check2 = false;
            }
            if (Input.GetButtonUp("Fire1"))
            {
                RpcSetInputButtonUp(true);
            }
            else
            {
                RpcSetInputButtonUp(false);
            }
        }


        if (Input.touchCount > 0)
        {
            var inputPosition = Input.GetTouch(0).position;
            this.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(inputPosition.x, inputPosition.y, 0.5f));
        }
    }