コード例 #1
0
ファイル: OSCPingClientEditor.cs プロジェクト: Iam1337/extOSC
        protected override void DrawSettings()
        {
            _defaultColor = GUI.color;

            // PING SETTINGS
            EditorGUILayout.LabelField(_pingSettingsContent, EditorStyles.boldLabel);
            using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
            {
                EditorGUILayout.PropertyField(_intervalProperty, _intervalContent);
                EditorGUILayout.PropertyField(_timeoutProperty, _timeoutContent);
            }

            using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
            {
                GUI.color = _autoStartProperty.boolValue ? Color.green : Color.red;
                if (GUILayout.Button(_autoStartContent))
                {
                    _autoStartProperty.boolValue = !_autoStartProperty.boolValue;
                }

                GUI.color = _defaultColor;
            }

            GUI.enabled = Application.isPlaying;

            EditorGUILayout.LabelField(_inGameContent, EditorStyles.boldLabel);
            using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
            {
                if ((!_ping.IsRunning && !Application.isPlaying && !_ping.AutoStart) ||
                    (Application.isPlaying && !_ping.IsRunning))
                {
                    GUI.color = Color.green;
                    if (GUILayout.Button(_startContent))
                    {
                        _ping.StartPing();
                    }

                    GUI.color = _defaultColor;
                }
                else
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        GUI.color = Color.yellow;
                        if (GUILayout.Button(_pauseContent))
                        {
                            _ping.PausePing();
                        }

                        GUI.color = Color.red;
                        if (GUILayout.Button(_stopContent))
                        {
                            _ping.StopPing();
                        }

                        GUI.color = _defaultColor;
                    }
                }
            }

            GUI.enabled = true;

            EditorGUILayout.LabelField(_pingStatusContent, EditorStyles.boldLabel);
            using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
            {
                _drawedState = _ping.IsAvailable;

                GUI.color = _drawedState ? Color.green : Color.red;
                using (new GUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    EditorGUILayout.LabelField(_drawedState ? "Available" : "Not Available", OSCEditorStyles.CenterLabel);
                }

                GUI.color = _defaultColor;
            }
        }
コード例 #2
0
        protected override void DrawSettings()
        {
            _defaultColor = GUI.color;

            // PING SETTINGS
            EditorGUILayout.LabelField(_pingSettingsContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical("box");

            EditorGUILayout.PropertyField(_intervalProperty, _intervalContent);
            EditorGUILayout.PropertyField(_timeoutProperty, _timeoutContent);

            // PING SETTINGS END
            EditorGUILayout.EndVertical();

            GUILayout.BeginVertical("box");

            GUI.color = _autoStartProperty.boolValue ? Color.green : Color.red;
            if (GUILayout.Button(_autoStartContent))
            {
                _autoStartProperty.boolValue = !_autoStartProperty.boolValue;
            }
            GUI.color = _defaultColor;

            GUILayout.EndVertical();

            GUI.enabled = Application.isPlaying;

            EditorGUILayout.LabelField(_inGameContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical("box");

            if ((!_ping.IsRunning && (!Application.isPlaying && !_ping.AutoStart)) ||
                (Application.isPlaying && !_ping.IsRunning))
            {
                GUI.color = Color.green;

                var play = GUILayout.Button(_startContent);
                if (play)
                {
                    _ping.StartPing();
                }

                GUI.color = _defaultColor;
            }
            else
            {
                GUILayout.BeginHorizontal();

                GUI.color = Color.yellow;

                var pause = GUILayout.Button(_pauseContent);
                if (pause)
                {
                    _ping.PausePing();
                }

                GUI.color = Color.red;

                var stop = GUILayout.Button(_stopContent);
                if (stop)
                {
                    _ping.StopPing();
                }

                GUI.color = _defaultColor;

                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();

            GUI.enabled = true;

            EditorGUILayout.LabelField(_pingStatusContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical("box");

            _drawedState = _ping.IsAvaible;

            GUI.color = _drawedState ? Color.green : Color.red;
            GUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField(_drawedState ? "Avaible" : "Not Avaible", OSCEditorStyles.CenterLabel);
            GUILayout.EndVertical();
            GUI.color = _defaultColor;

            GUILayout.EndVertical();
        }