Exemplo n.º 1
0
        /// <summary>
        /// Called when a new user is leaving.
        /// </summary>
        private void SessionUsersTracker_UserLeft(User user)
        {
            if (remoteHeads.ContainsKey(user.GetID()))
            {
#if UNITY_EDITOR
                if (HolographicCameraManager.Instance != null &&
                    remoteHeads[user.GetID()].IP != null &&
                    remoteHeads[user.GetID()].IP == HolographicCameraManager.Instance.HolographicCameraIP.Trim() &&
                    HolographicCameraManager.Instance.HolographicCameraIP.Trim() != String.Empty)
                {
                    networkMovement = null;
                    HolographicCameraManager.Instance.ResetHolographicCamera();

                    // if flag was not set
                    if (SV_Settings.Instance.SV_User_Connected)
                    {
                        SV_Settings.Instance.On_SV_UserDisconnected();
                    }

                    // is Spectator view user connected?
                    SV_Settings.Instance.SV_User_Connected = false;
                }
#endif

                RemoveRemoteHead(remoteHeads[user.GetID()].HeadObject);
                remoteHeads.Remove(user.GetID());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called when a remote user sends a head transform.
        /// </summary>
        /// <param name="msg"></param>
        void UpdateHeadTransform(NetworkInMessage msg)
        {
            // Parse the message
            long userID = msg.ReadInt64();
            long ipSize = msg.ReadInt64();

            byte[] ipData = new byte[(uint)ipSize];
            msg.ReadArray(ipData, (uint)ipSize);

            Vector3    headPos = SV_CustomMessages.Instance.ReadVector3(msg);
            Quaternion headRot = SV_CustomMessages.Instance.ReadQuaternion(msg);

            RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

            if (headInfo.HeadObject != null)
            {
#if UNITY_EDITOR
                if (HolographicCameraManager.Instance != null &&
                    HolographicCameraManager.Instance.tppcUser != null &&
                    HolographicCameraManager.Instance.tppcUser.GetID() == userID)
                {
                    if (SV_Cam == null)
                    {
                        SV_Cam = headInfo.HeadObject.AddComponent <SV_Camera>();
                    }

                    if (networkMovement == null)
                    {
                        networkMovement = headInfo.HeadObject.AddComponent <NetworkMovement>();
                    }

                    // update SV_cam info
                    SV_Cam.info = headInfo;
                    // update SV_cam position and rotation
                    SV_Cam.position = headPos;
                    SV_Cam.rotation = headRot;

                    networkMovement.AddTransform(
                        new NetworkMovement.NetworkTransform()
                    {
                        Position = headPos,
                        Rotation = headRot
                    }
                        );
                }
                else
#endif
                {
                    headInfo.HeadObject.transform.localPosition = headPos;
                    headInfo.HeadObject.transform.localRotation = headRot;
                }

                if (string.IsNullOrEmpty(headInfo.IP))
                {
                    headInfo.IP = System.Text.Encoding.ASCII.GetString(ipData);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called when a new user is leaving.
        /// </summary>
        private void SessionUsersTracker_UserLeft(User user)
        {
            if (remoteHeads.ContainsKey(user.GetID()))
            {
#if UNITY_EDITOR
                if (HolographicCameraManager.Instance != null &&
                    remoteHeads[user.GetID()].IP != null &&
                    remoteHeads[user.GetID()].IP == HolographicCameraManager.Instance.HolographicCameraIP.Trim() &&
                    HolographicCameraManager.Instance.HolographicCameraIP.Trim() != String.Empty)
                {
                    networkMovement = null;
                    HolographicCameraManager.Instance.ResetHolographicCamera();
                }
#endif

                RemoveRemoteHead(remoteHeads[user.GetID()].HeadObject);
                remoteHeads.Remove(user.GetID());
            }
        }