Exemple #1
0
        private void DrawControls(OSCEditorBase editorBase, out bool remove)
        {
            var connect   = false;
            var reconnect = false;

            using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
            {
                GUI.color = editorBase.IsStarted ? Color.green : Color.red;
                connect   = GUILayout.Button(editorBase.IsStarted ? "Connected" : "Disconnected");

                using (new GUILayout.HorizontalScope(OSCEditorStyles.Box))
                {
                    GUI.color = Color.yellow;
                    EditorGUI.BeginDisabledGroup(!editorBase.IsStarted);
                    reconnect = GUILayout.Button("Reconnect");
                    EditorGUI.EndDisabledGroup();

                    GUI.color = Color.red;
                    remove    = GUILayout.Button("Remove");
                }
            }

            // Actions
            if (connect)
            {
                if (editorBase.IsStarted)
                {
                    editorBase.Close();
                }
                else
                {
                    editorBase.Connect();
                }
            }

            if (reconnect)
            {
                if (editorBase.IsStarted)
                {
                    editorBase.Close();
                }

                editorBase.Connect();
            }
        }
Exemple #2
0
        private void DrawBase(OSCEditorBase editorBase, out bool remove)
        {
            var stateColor = (editorBase.IsStarted ? Color.green : Color.yellow) + new Color(0.75f, 0.75f, 0.75f);

            remove = false;

            GUI.color = stateColor;
            using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
            {
                // OSC Name
                GUI.color = editorBase.IsStarted ? Color.green : Color.yellow;
                using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
                {
                    GUI.color = Color.white;
                    GUILayout.Label(extOSC.InEditor.OSCEditorUtils.GetName(editorBase), OSCEditorStyles.CenterBoldLabel);
                    GUI.color = stateColor;
                }
                GUI.color = stateColor;

                // OSC Settings
                GUI.color = Color.white;
                if (editorBase is OSCEditorReceiver receiver)
                {
                    DrawReceiver(receiver);
                }
                else if (editorBase is OSCEditorTransmitter transmitter)
                {
                    DrawTransmitter(transmitter);
                }
                GUI.color = stateColor;

                // OSC Control
                GUI.color = Color.white;
                using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
                {
                    EditorGUILayout.LabelField(_controlsContent, EditorStyles.boldLabel);
                    DrawControls(editorBase, out remove);
                }
                GUI.color = stateColor;
            }

            GUI.color = _defaultColor;
        }