Пример #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Rect optionsRect = RectUtility.SliceVertical(position, buttonsHeight, out position);

            if (typeNames == null)
            {
                RefreshTypeList(property);
            }

            //Draw type selection popup
            Rect popupRect = RectUtility.SliceHoriozntal(optionsRect, position.width - 25, out Rect menuPosition);

            selected = EditorGUI.IntPopup(popupRect, selected, typeNames, optionsValue);

            if (GUI.Button(RectUtility.SliceHoriozntal(menuPosition, 5, false), "...", EditorStyles.miniButtonRight)) //TODO: Add icon
            {
                var menu = new GenericMenu();
                menu.AddItem(new GUIContent("Inject"), false, OnInjectSelectedTypeSelected, property);
                menu.AddItem(new GUIContent("Refresh"), false, OnRefreshTypeListSelected, property);
                menu.DropDown(menuPosition);
            }

            //Draw property field
            EditorGUI.PropertyField(position, property, new GUIContent(property.displayName), true);
        }
Пример #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            GT_MinMaxRangeAttribute minMaxRangeAttr = attribute as GT_MinMaxRangeAttribute;
            Rect labelRect = RectUtility.SliceVertical(position, EditorGUIUtility.singleLineHeight, out Rect slidersRect);

            EditorGUI.LabelField(labelRect, minMaxRangeAttr.Name);
            SerializedProperty minSliderProp = property.serializedObject.FindProperty(property.propertyPath);

            if (property.Next(false))
            {
                SerializedProperty maxSliderProp = property;
                if (string.IsNullOrEmpty(maxSliderControlName))
                {
                    maxSliderControlName = "Slider_" + maxSliderProp.name;
                }


                if (minSliderProp.propertyType != maxSliderProp.propertyType)
                {
                    EditorGUI.HelpBox(position, "Properties type don't match", MessageType.Warning);
                    return;
                }


                Rect minSliderRect = RectUtility.SliceHoriozntal(slidersRect, 10, false); // make 10 pixel indent
                minSliderRect = RectUtility.SliceVertical(minSliderRect, EditorGUI.GetPropertyHeight(property), out Rect maxSliderRect);

                EditorGUI.BeginChangeCheck();
                DrawSlider(minSliderRect, minSliderProp, "Min", minMaxRangeAttr.Min, minMaxRangeAttr.Max);
                if (EditorGUI.EndChangeCheck())
                {
                    ChangeValue(minSliderProp, maxSliderProp, false);
                }

                EditorGUI.BeginChangeCheck();

                GUI.SetNextControlName(maxSliderControlName);
                DrawSlider(maxSliderRect, maxSliderProp, "Max", minMaxRangeAttr.Min, minMaxRangeAttr.Max);

                if ((EditorGUI.EndChangeCheck() && EditorGUIUtility.editingTextField == false) ||
                    GUI.GetNameOfFocusedControl() != maxSliderControlName)
                {
                    ChangeValue(minSliderProp, maxSliderProp);
                }
            }
        }
Пример #3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            int propertiesCount = (attribute as GT_MultiPropertiesAttribute).PropertiesCount;

            position = RectUtility.SliceVertical(position, height - EditorGUIUtility.standardVerticalSpacing);
            Rect[][] spliteRects = RectUtility.Split(position, propertiesCount, 2, 5, 0);

            for (int i = 0; i < propertiesCount; i++)
            {
                EditorGUI.PrefixLabel(spliteRects[0][i], new GUIContent(property.displayName));
                EditorGUI.PropertyField(spliteRects[1][i], property, GUIContent.none);

                if (property.Next(false) == false)
                {
                    break;
                }
            }
        }