Skip to content

Commit

Permalink
Improvements to ScriptableObject with header/space attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChemiKhazi committed Oct 19, 2017
1 parent 012bde4 commit 31861b7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Editor/ReorderableArrayInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ protected virtual void InitInspector()
if (isInitialized && FORCE_INIT == false)
return;

styleEditBox = new GUIStyle(EditorStyles.helpBox) { padding = new RectOffset(10, 5, 5, 5) };
styleEditBox = new GUIStyle(EditorStyles.helpBox) { padding = new RectOffset(5, 5, 5, 5) };
FindTargetProperties();
FindContextMenu();
}
Expand Down Expand Up @@ -688,8 +688,15 @@ protected void DrawPropertySortableArray(SerializedProperty property)
// Else try to draw ScriptableObject editor
else if (isScriptableEditor)
{
bool hasHeader = property.HasAttribute<HeaderAttribute>();
bool hasSpace = property.HasAttribute<SpaceAttribute>();

float foldoutSpace = hasHeader ? 24 : 7;
if (hasHeader && hasSpace)
foldoutSpace = 31;

hasSpace |= hasHeader;

// No data in property, draw property field with create button
if (scriptableEditor == null)
{
Expand Down Expand Up @@ -722,7 +729,7 @@ protected void DrawPropertySortableArray(SerializedProperty property)

Rect rectFoldout = GUILayoutUtility.GetLastRect();
rectFoldout.width = 20;
if (hasSpace) rectFoldout.yMin += 7;
if (hasSpace) rectFoldout.yMin += foldoutSpace;

property.isExpanded = EditorGUI.Foldout(rectFoldout, property.isExpanded, GUIContent.none);

Expand All @@ -732,7 +739,7 @@ protected void DrawPropertySortableArray(SerializedProperty property)
using (new EditorGUILayout.VerticalScope(styleEditBox))
{
var restoreIndent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
EditorGUI.indentLevel = 1;
scriptableEditor.serializedObject.Update();
scriptableEditor.OnInspectorGUI();
scriptableEditor.serializedObject.ApplyModifiedProperties();
Expand Down

0 comments on commit 31861b7

Please sign in to comment.