Esempio n. 1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (property.propertyType != SerializedPropertyType.ObjectReference)
            {
                return;
            }

            var fieldType = fieldInfo.FieldType;

            if (fieldType == _transmitterType)
            {
                OSCEditorUtils.FindObjects(TransmitterCallback, true, out var content, out OSCTransmitter[] objects);

                property.objectReferenceValue = OSCEditorInterface.Popup(position, label,
                                                                         (OSCTransmitter)property.objectReferenceValue,
                                                                         content,
                                                                         objects);
            }
            else if (fieldType == _receiverType)
            {
                OSCEditorUtils.FindObjects(ReceiverCallback, true, out var content, out OSCReceiver[] objects);

                property.objectReferenceValue = OSCEditorInterface.Popup(position, label,
                                                                         (OSCReceiver)property.objectReferenceValue,
                                                                         content,
                                                                         objects);
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUI.BeginChangeCheck();

            // LOGO
            OSCEditorInterface.LogoLayout();

            using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
            {
                EditorGUILayout.LabelField(_transmitterComponentSettingsContent, EditorStyles.boldLabel);
                using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
                {
                    OSCEditorInterface.TransmitterSettings(_transmitterProperty, _addressProperty, false);
                    EditorGUILayout.PropertyField(_mapBundleProperty, _mapBundleContent);

                    if (_transmitterComponent.Transmitter != null &&
                        _transmitterComponent.Transmitter.MapBundle != null &&
                        _transmitterComponent.MapBundle != null)
                    {
                        EditorGUILayout.HelpBox("OSCTransmitter already has MapBundle.", MessageType.Info);
                    }
                }

                DrawSettings();
            }

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
Esempio n. 3
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUI.BeginChangeCheck();

            // LOGO
            OSCEditorInterface.LogoLayout();

            EditorGUILayout.LabelField(_settingsTitleContent, EditorStyles.boldLabel);
            using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
            {
                EditorGUILayout.LabelField(_transmitterComponentSettingsContent, EditorStyles.boldLabel);
                OSCEditorInterface.TransmitterSettings(_transmitterProperty, _transmitterAddressProperty);

                EditorGUILayout.LabelField(_receiverComponentSettingsContent, EditorStyles.boldLabel);
                OSCEditorInterface.ReceiverSettings(_receiverProperty, _receiverAddressProperty);

                DrawSettings();
            }

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
        protected virtual void DrawSettings()
        {
            // CUSTOM SETTINGS
            EditorGUILayout.LabelField(_otherSettingsContent, EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical(OSCEditorStyles.Box);

            OSCEditorInterface.DrawProperties(serializedObject, _addressProperty.name, _transmitterProperty.name, _mapBundleProperty.name);

            EditorGUILayout.EndVertical();
        }
Esempio n. 5
0
 protected virtual void DrawSettings()
 {
     // CUSTOM SETTINGS
     EditorGUILayout.LabelField(_otherSettingsContent, EditorStyles.boldLabel);
     using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
     {
         OSCEditorInterface.DrawProperties(serializedObject, _transmitterAddressProperty.name,
                                           _transmitterProperty.name, _receiverAddressProperty.name,
                                           _receiverProperty.name);
     }
 }
Esempio n. 6
0
        public override void OnInspectorGUI()
        {
            OSCEditorInterface.LogoLayout();

            GUILayout.Label(string.Format("Value: {0}", _valueProperty.floatValue), EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);

            GUILayout.Label(_settingsContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);
            base.OnInspectorGUI();
            GUILayout.EndVertical();

            serializedObject.Update();

            GUILayout.Label(_rotartySettingsContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);
            EditorGUILayout.PropertyField(_handleImageProperty);
            EditorGUILayout.PropertyField(_reverseProperty);

            GUILayout.EndVertical();

            GUILayout.Label(_valueSettingsContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(_minValueProperty);
            EditorGUILayout.PropertyField(_maxValueProperty);

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(_wholeNumbersProperty);

            EditorGUILayout.Space();

            EditorGUILayout.Slider(_valueProperty, _minValueProperty.floatValue, _maxValueProperty.floatValue);

            GUILayout.EndVertical();

            GUILayout.Label(_resetValueContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);
            EditorGUILayout.PropertyField(_resetValueProperty);
            EditorGUILayout.PropertyField(_resetValueTimeProperty);
            EditorGUILayout.PropertyField(_callbackOnResetProperty);
            GUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(_onValueChangedProperty);

            GUILayout.EndVertical();
            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 7
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUI.BeginChangeCheck();

            // LOGO
            OSCEditorInterface.LogoLayout();

            EditorGUILayout.LabelField(string.Format("{0} Settings:", target.GetType().Name), EditorStyles.boldLabel);
            using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
            {
                EditorGUILayout.LabelField(_receiverComponentSettingsContent, EditorStyles.boldLabel);
                OSCEditorInterface.ReceiverSettings(_receiverProperty, _receiverAddressProperty);

                EditorGUILayout.LabelField(_transmitterComponentSettingsContent, EditorStyles.boldLabel);
                using (new GUILayout.VerticalScope(OSCEditorStyles.Box))
                {
                    EditorGUILayout.PropertyField(_transmitterProperty, _transmitterContent);

                    var transmitterAddress = "- None -";

                    if (Application.isPlaying)
                    {
                        transmitterAddress = _ping.TransmitterAddress;
                    }

                    EditorGUILayout.LabelField(EditorGUIUtility.currentViewWidth > 410
                                                                   ? _transmitterAddressContent.text
                                                                   : _transmitterAddressContentSmall.text,
                                               transmitterAddress);
                }

                DrawSettings();
            }

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
Esempio n. 8
0
        public override void OnInspectorGUI()
        {
            OSCEditorInterface.LogoLayout();

            GUILayout.Label(string.Format("Value: {0}", _valueProperty.boolValue), EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);

            GUILayout.Label(_settingsContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);
            base.OnInspectorGUI();
            GUILayout.EndVertical();

            serializedObject.Update();

            GUILayout.Label(_buttonSettingsContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);
            EditorGUILayout.PropertyField(_graphicProperty);
            EditorGUILayout.PropertyField(_graphicTransitionProperty);
            EditorGUILayout.PropertyField(_buttonTypeProperty);
            GUILayout.EndVertical();

            if ((OSCButton.Type)_buttonTypeProperty.enumValueIndex == OSCButton.Type.Toggle)
            {
                GUILayout.Label(_valueSettingsContent, EditorStyles.boldLabel);
                GUILayout.BeginVertical(OSCEditorStyles.Box);
                EditorGUILayout.PropertyField(_valueProperty);
                GUILayout.EndVertical();
            }

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(_onValueChangedProperty);

            GUILayout.EndVertical();

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 9
0
        protected override void DrawContent(ref Rect contentRect)
        {
            if (!_controlCreator.IsValid)
            {
                EditorGUILayout.LabelField(_errorCreateContent, OSCEditorStyles.CenterLabel, GUILayout.Height(contentRect.height));

                return;
            }

            contentRect.x      += 2;
            contentRect.y      += 2;
            contentRect.width  -= 4;
            contentRect.height -= 4;

            GUILayout.BeginArea(contentRect);

            OSCEditorInterface.LogoLayout();

            GUILayout.Label(_controlSettingsContent, EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical(OSCEditorStyles.Box);

            ControlColor = EditorGUILayout.ColorField(_controlColorContent, ControlColor);

            EditorGUILayout.EndVertical();

            GUI.color = AddInformer ? Color.green : Color.red;
            if (GUILayout.Button(_addInformerContent))
            {
                AddInformer = !AddInformer;
            }

            GUI.color = Color.white;

            if (AddInformer)
            {
                GUILayout.Label(_informerSettingsContent, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(OSCEditorStyles.Box);

                OSCEditorUtils.FindObjects(TransmitterCallback, true, out var content, out OSCTransmitter[] objects);

                InformerAddress     = EditorGUILayout.TextField(_oscAddressContent, InformerAddress);
                InformerTransmitter = OSCEditorInterface.PopupLayout(_oscTransmitterContent,
                                                                     InformerTransmitter,
                                                                     content,
                                                                     objects);

                GUI.color = InformOnChanged ? Color.green : Color.red;
                if (GUILayout.Button(_informOnChangedContent))
                {
                    InformOnChanged = !InformOnChanged;
                }

                GUI.color = Color.white;

                if (!InformOnChanged)
                {
                    InformerInterval = EditorGUILayout.FloatField(_informerIntervalContent, InformerInterval);

                    if (InformerInterval < 0)
                    {
                        InformerInterval = 0;
                    }

                    EditorGUILayout.HelpBox("Set to 0 for send message with each frame.", MessageType.Info);
                }

                EditorGUILayout.EndVertical();
            }

            GUI.color = Color.green;
            if (GUILayout.Button(_createContent))
            {
                var data = new OSCWindowControlCreator.ControlData();
                data.ControlColor        = ControlColor;
                data.UseInformer         = AddInformer;
                data.InformAddress       = InformerAddress;
                data.InformInterval      = InformerInterval;
                data.InformOnChanged     = InformOnChanged;
                data.InformerTransmitter = InformerTransmitter;

                OSCWindowControlCreator.CreateControl(data);
            }

            GUI.color = Color.white;

            GUILayout.EndArea();
        }
Esempio n. 10
0
        public override void OnInspectorGUI()
        {
            OSCEditorInterface.LogoLayout();

            GUILayout.Label($"Value: {_valueProperty.floatValue}", EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);

            GUILayout.Label(_settingsContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);
            base.OnInspectorGUI();
            GUILayout.EndVertical();

            serializedObject.Update();

            GUILayout.Label(_sliderSettingsContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);
            EditorGUILayout.PropertyField(_fillRecrProperty);
            EditorGUILayout.PropertyField(_handleProperty);
            EditorGUILayout.PropertyField(_multiplyControllerProperty);

            if (_fillRecrProperty.objectReferenceValue != null || _handleProperty.objectReferenceValue != null)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(_directionProperty);
                if (EditorGUI.EndChangeCheck())
                {
                    Slider.Direction direction = (Slider.Direction)_directionProperty.enumValueIndex;
                    foreach (var targetObject in serializedObject.targetObjects)
                    {
                        var slider = targetObject as Slider;
                        if (slider != null)
                        {
                            slider.SetDirection(direction, true);
                        }
                    }
                }

                GUILayout.EndVertical();

                GUILayout.Label(_valueSettingsContent, EditorStyles.boldLabel);
                GUILayout.BeginVertical(OSCEditorStyles.Box);
                EditorGUILayout.PropertyField(_minValueProperty);
                EditorGUILayout.PropertyField(_maxValueProperty);
                EditorGUILayout.PropertyField(_wholeNumbersProperty);
                EditorGUILayout.Slider(_valueProperty, _minValueProperty.floatValue, _maxValueProperty.floatValue);
                GUILayout.EndVertical();

                GUILayout.Label(_resetValueContent, EditorStyles.boldLabel);
                GUILayout.BeginVertical(OSCEditorStyles.Box);
                EditorGUILayout.PropertyField(_resetValueProperty);
                EditorGUILayout.PropertyField(_resetValueTimeProperty);
                EditorGUILayout.PropertyField(_callbackOnResetProperty);
                GUILayout.EndVertical();

                bool warning = false;
                foreach (var targetObject in serializedObject.targetObjects)
                {
                    if (targetObject is Slider slider)
                    {
                        var direction = slider.direction;
                        if (direction == Slider.Direction.LeftToRight || direction == Slider.Direction.RightToLeft)
                        {
                            warning = (slider.navigation.mode != Navigation.Mode.Automatic && (slider.FindSelectableOnLeft() != null || slider.FindSelectableOnRight() != null));
                        }
                        else
                        {
                            warning = (slider.navigation.mode != Navigation.Mode.Automatic && (slider.FindSelectableOnDown() != null || slider.FindSelectableOnUp() != null));
                        }
                    }
                }

                if (warning)
                {
                    EditorGUILayout.HelpBox("The selected slider direction conflicts with navigation. Not all navigation options may work.", MessageType.Warning);
                }

                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(_onValueChangedProperty);
            }
            else
            {
                GUILayout.EndVertical();
                EditorGUILayout.HelpBox("Specify a RectTransform for the slider fill or the slider handle or both. Each must have a parent RectTransform that it can slide within.", MessageType.Info);
            }

            GUILayout.EndVertical();

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 11
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            OSCEditorInterface.LogoLayout();

            GUILayout.Label($"Sliders: {_slidersProperty.arraySize}", EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);

            GUILayout.Label("Settings:", EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);
            base.OnInspectorGUI();
            GUILayout.EndVertical();

            GUILayout.Label("Multiply Sliders Settings:", EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);
            EditorGUILayout.PropertyField(_layoutGroupProperty);

            if (_layoutGroupProperty.objectReferenceValue != null)
            {
                GUILayout.EndVertical();

                GUILayout.Label("Sliders Settings:", EditorStyles.boldLabel);
                GUILayout.BeginVertical(OSCEditorStyles.Box);
                EditorGUILayout.PropertyField(_defaultColorProperty);
                EditorGUILayout.PropertyField(_addressProperty);

                //OSCEditorLayout.TransmittersPopup(_transmitterProperty, new GUIContent("Transmitter"));
                EditorGUILayout.PropertyField(_transmitterProperty, new GUIContent("Transmitter"));
                GUILayout.EndVertical();

                GUILayout.BeginHorizontal(OSCEditorStyles.Box);
                GUILayout.BeginVertical(OSCEditorStyles.Box);
                GUI.color = Color.red;
                var removeButton = GUILayout.Button("-", GUILayout.Width(20), GUILayout.Height(20));
                GUI.color = Color.white;
                GUILayout.EndVertical();
                GUILayout.BeginVertical(OSCEditorStyles.Box);
                EditorGUILayout.LabelField(_slidersProperty.arraySize.ToString(), OSCEditorStyles.CenterLabel, GUILayout.Height(20));
                GUILayout.EndVertical();
                GUILayout.BeginVertical(OSCEditorStyles.Box);
                GUI.color = Color.green;
                var createButton = GUILayout.Button("+", GUILayout.Width(20), GUILayout.Height(20));
                GUI.color = Color.white;
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();

                GUILayout.Label("Value Settings:", EditorStyles.boldLabel);
                GUILayout.BeginVertical(OSCEditorStyles.Box);
                EditorGUILayout.PropertyField(_minValueProperty);
                EditorGUILayout.PropertyField(_maxValueProperty);
                EditorGUILayout.PropertyField(_wholeNumbersProperty);
                GUILayout.EndVertical();

                GUILayout.EndVertical();

                if (createButton)
                {
                    AddSlider();
                }
                if (removeButton)
                {
                    RemoveSlider();
                }
            }
            else
            {
                EditorGUILayout.HelpBox("You need to set \"HorizontalOrVerticalLayoutGroup Group\" for correct work of the component.", MessageType.Warning);
                GUILayout.EndVertical();
            }

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 12
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            OSCEditorInterface.LogoLayout();

            GUILayout.Label($"Value: {_valueProperty.vector2Value}", EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);

            GUILayout.Label(_settingsContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);
            base.OnInspectorGUI();
            GUILayout.EndVertical();

            GUILayout.Label(_padSettingsContent, EditorStyles.boldLabel);
            GUILayout.BeginVertical(OSCEditorStyles.Box);
            EditorGUILayout.PropertyField(_handleRectProperty);

            if (_handleRectProperty.objectReferenceValue != null)
            {
                EditorGUILayout.PropertyField(_handleAlignmentProperty);
                GUILayout.EndVertical();

                var minX = _minValueProperty.FindPropertyRelative("x");
                var maxX = _maxValueProperty.FindPropertyRelative("x");
                var minY = _minValueProperty.FindPropertyRelative("y");
                var maxY = _maxValueProperty.FindPropertyRelative("y");

                GUILayout.Label(_valueSettingsContent, EditorStyles.boldLabel);
                GUILayout.BeginVertical(OSCEditorStyles.Box);
                EditorGUILayout.PropertyField(_xAxisRectProperty);
                EditorGUILayout.PropertyField(_yAxisRectProperty);

                EditorGUILayout.Space();

                EditorGUILayout.LabelField(_xAxisContent);
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(minX, _minContent);
                EditorGUILayout.PropertyField(maxX, _maxContent);
                EditorGUI.indentLevel--;

                EditorGUILayout.Space();

                EditorGUILayout.LabelField(_yAxisContent);
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(minY, _minContent);
                EditorGUILayout.PropertyField(maxY, _maxContent);
                EditorGUI.indentLevel--;

                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(_wholeNumbersProperty);

                EditorGUILayout.Space();

                EditorGUILayout.LabelField(_valueContent);
                EditorGUI.indentLevel++;
                EditorGUILayout.Slider(_valueProperty.FindPropertyRelative("x"), minX.floatValue, maxX.floatValue);
                EditorGUILayout.Slider(_valueProperty.FindPropertyRelative("y"), minY.floatValue, maxY.floatValue);
                EditorGUI.indentLevel--;

                GUILayout.EndVertical();

                GUILayout.Label(_resetValueContent, EditorStyles.boldLabel);
                GUILayout.BeginVertical(OSCEditorStyles.Box);
                EditorGUILayout.PropertyField(_resetValueProperty);
                EditorGUILayout.PropertyField(_resetValueTimeProperty);
                EditorGUILayout.PropertyField(_callbackOnResetProperty);
                GUILayout.EndVertical();

                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(_onValueChangedProperty);
            }
            else
            {
                GUILayout.EndVertical();
                EditorGUILayout.HelpBox("You need to set \"RectTransform Group\" for correct work of the component.", MessageType.Info);
            }

            GUILayout.EndVertical();
            serializedObject.ApplyModifiedProperties();
        }