Skip to content

Commit

Permalink
dbrizov#133 another small boost
Browse files Browse the repository at this point in the history
  • Loading branch information
niggo1243 committed Sep 6, 2021
1 parent b35d73c commit 85d38ea
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions Assets/NaughtyAttributes/Scripts/Editor/NaughtyInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ protected virtual void OnDisable()
ReorderableListPropertyDrawer.Instance.ClearCache();
}


public override void OnInspectorGUI()
{
if (!_anyNaughtyAttribute)
Expand All @@ -77,9 +76,11 @@ public override void OnInspectorGUI()
DrawButtons();
}

protected void GetSerializedProperties(ref List<NaughtyProperty> outSerializedProperties)
protected virtual void GetSerializedProperties(ref List<NaughtyProperty> outSerializedProperties)
{
outSerializedProperties.Clear();
outSerializedProperties.TrimExcess();

using (var iterator = serializedObject.GetIterator())
{
if (iterator.NextVisible(true))
Expand All @@ -95,7 +96,7 @@ protected void GetSerializedProperties(ref List<NaughtyProperty> outSerializedPr
}
}

protected void DrawSerializedProperties()
protected virtual void DrawSerializedProperties()
{
serializedObject.Update();

Expand All @@ -108,24 +109,24 @@ protected void DrawSerializedProperties()
}

// Draw non-grouped serialized properties
foreach (var property in _nonGroupedSerializedProperty)
foreach (var naughtyProperty in _nonGroupedSerializedProperty)
{
NaughtyEditorGUI.PropertyField_Layout(property, includeChildren: true);
NaughtyEditorGUI.PropertyField_Layout(naughtyProperty, includeChildren: true);
}

// Draw grouped serialized properties
foreach (var group in _groupedSerialzedProperty)
{
IEnumerable<NaughtyProperty> visibleProperties = group.Where(p => PropertyUtility.IsVisible(p.serializedProperty));
IEnumerable<NaughtyProperty> visibleProperties = group.Where(p => PropertyUtility.IsVisible(p.showIfAttribute, p.serializedProperty));
if (!visibleProperties.Any())
{
continue;
}

NaughtyEditorGUI.BeginBoxGroup_Layout(group.Key);
foreach (var property in visibleProperties)
foreach (var naughtyProperty in visibleProperties)
{
NaughtyEditorGUI.PropertyField_Layout(property, includeChildren: true);
NaughtyEditorGUI.PropertyField_Layout(naughtyProperty, includeChildren: true);
}

NaughtyEditorGUI.EndBoxGroup_Layout();
Expand All @@ -134,7 +135,7 @@ protected void DrawSerializedProperties()
// Draw foldout serialized properties
foreach (var group in _foldoutGroupedSerializedProperty)
{
IEnumerable<NaughtyProperty> visibleProperties = group.Where(p => PropertyUtility.IsVisible(p.serializedProperty));
IEnumerable<NaughtyProperty> visibleProperties = group.Where(p => PropertyUtility.IsVisible(p.showIfAttribute, p.serializedProperty));
if (!visibleProperties.Any())
{
continue;
Expand All @@ -148,17 +149,17 @@ protected void DrawSerializedProperties()
_foldouts[group.Key].Value = EditorGUILayout.Foldout(_foldouts[group.Key].Value, group.Key, true);
if (_foldouts[group.Key].Value)
{
foreach (var property in visibleProperties)
foreach (var naughtyProperty in visibleProperties)
{
NaughtyEditorGUI.PropertyField_Layout(property, true);
NaughtyEditorGUI.PropertyField_Layout(naughtyProperty, true);
}
}
}

serializedObject.ApplyModifiedProperties();
}

protected void DrawNonSerializedFields(bool drawHeader = false)
protected virtual void DrawNonSerializedFields(bool drawHeader = false)
{
if (_nonSerializedFields.Any())
{
Expand All @@ -177,7 +178,7 @@ protected void DrawNonSerializedFields(bool drawHeader = false)
}
}

protected void DrawNativeProperties(bool drawHeader = false)
protected virtual void DrawNativeProperties(bool drawHeader = false)
{
if (_nativeProperties.Any())
{
Expand All @@ -196,7 +197,7 @@ protected void DrawNativeProperties(bool drawHeader = false)
}
}

protected void DrawButtons(bool drawHeader = false)
protected virtual void DrawButtons(bool drawHeader = false)
{
if (_methods.Any())
{
Expand Down

0 comments on commit 85d38ea

Please sign in to comment.