Example #1
0
 public void DrawSlider(Rect rect, SerializedProperty property, PercentSliderAttribute attribute)
 {
     if (property.propertyType == SerializedPropertyType.Float)
     {
         property.floatValue = attribute.Option.Contains(FieldOption.HideLabel)
             ? EditorGUI.Slider(rect, property.floatValue * 100, 0, 100) / 100
             : EditorGUI.Slider(rect, property.displayName, property.floatValue * 100, 0, 100) / 100;
         GUI.Label(rect, "%");
     }
     else
     {
         EditorDrawUtility.DrawPropertyField(rect, property);
         rect.y      += 18;
         rect.height -= 24;
         EditorDrawUtility.DrawHelpBox(rect, $"{typeof(PercentSliderAttribute).Name} can be used only on float fields");
     }
 }
Example #2
0
 public void DrawSlider(SerializedProperty property, PercentSliderAttribute attribute, GUIContent label = null)
 {
     if (property.propertyType == SerializedPropertyType.Float)
     {
         GUILayout.BeginHorizontal();
         property.floatValue = attribute.Option.Contains(FieldOption.HideLabel)
             ? EditorGUILayout.Slider(property.floatValue * 100, 0, 100) / 100
             : EditorGUILayout.Slider(property.displayName, property.floatValue * 100, 0, 100) / 100;
         GUILayout.Label("%", GUILayout.Width(15));
         GUILayout.EndHorizontal();
     }
     else
     {
         EditorDrawUtility.DrawPropertyField(property);
         EditorDrawUtility.DrawHelpBox($"{typeof(PercentSliderAttribute).Name} can be used only on float fields");
     }
 }