Exemplo n.º 1
0
        private void HandleButtonPress()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                Debug.LogError("Unable to connect / disconnect remoting while playing.");
                return;
            }

            HolographicStreamerConnectionState connectionState = PerceptionRemoting.GetConnectionState();

            if (connectionState == HolographicStreamerConnectionState.Connecting ||
                connectionState == HolographicStreamerConnectionState.Connected)
            {
                Disconnect();
            }
            else if (RemoteMachineNameSpecified)
            {
                Connect();
            }
            else
            {
                Debug.LogError("Cannot connect without a remote machine address specified");
            }
        }
Exemplo n.º 2
0
        void ConnectionStateGUI()
        {
            if (s_ConnectedTexture == null)
            {
                s_ConnectedTexture    = EditorGUIUtility.LoadIconRequired("sv_icon_dot3_sml");
                s_ConnectingTexture   = EditorGUIUtility.LoadIconRequired("sv_icon_dot4_sml");
                s_DisconnectedTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot6_sml");
            }

            Texture2D  iconTexture;
            GUIContent labelContent;
            GUIContent buttonContent;
            HolographicStreamerConnectionState connectionState = PerceptionRemoting.GetConnectionState();

            switch (connectionState)
            {
            case HolographicStreamerConnectionState.Disconnected:
            default:
                iconTexture   = s_DisconnectedTexture;
                labelContent  = s_ConnectionStateDisconnectedText;
                buttonContent = s_ConnectionButtonConnectText;
                break;

            case HolographicStreamerConnectionState.Connecting:
                iconTexture   = s_ConnectingTexture;
                labelContent  = s_ConnectionStateConnectingText;
                buttonContent = s_ConnectionButtonDisconnectText;
                break;

            case HolographicStreamerConnectionState.Connected:
                iconTexture   = s_ConnectedTexture;
                labelContent  = s_ConnectionStateConnectedText;
                buttonContent = s_ConnectionButtonDisconnectText;
                break;
            }

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PrefixLabel(s_ConnectionStatusText, "Button");
            float iconSize = EditorGUIUtility.singleLineHeight;
            Rect  iconRect = GUILayoutUtility.GetRect(iconSize, iconSize, GUILayout.ExpandWidth(false));

            GUI.DrawTexture(iconRect, iconTexture);
            EditorGUILayout.LabelField(labelContent);

            EditorGUILayout.EndHorizontal();

            EditorGUI.BeginDisabledGroup(m_InPlayMode);
            bool pressed = EditorGUILayout.DropdownButton(buttonContent, FocusType.Passive, EditorStyles.miniButton);

            EditorGUI.EndDisabledGroup();

            if (pressed)
            {
                if (EditorGUIUtility.editingTextField)
                {
                    EditorGUIUtility.editingTextField = false;
                    GUIUtility.keyboardControl        = 0;
                }
                //we delay the call to let the RemoteMachineAddress control commit the value
                EditorApplication.CallDelayed(() =>
                {
                    HandleButtonPress();
                }, 0f);
            }
        }
Exemplo n.º 3
0
 private bool IsConnectedToRemoteDevice()
 {
     return(PerceptionRemoting.GetConnectionState() == HolographicStreamerConnectionState.Connected);
 }