Skip to content

Commit

Permalink
Update metas
Browse files Browse the repository at this point in the history
  • Loading branch information
uurha committed Apr 10, 2024
1 parent 758e28f commit 1ce2be2
Show file tree
Hide file tree
Showing 48 changed files with 181 additions and 148 deletions.
3 changes: 3 additions & 0 deletions Editor/CustomEditors/Attributes.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Better.Commons.EditorAddons.CustomEditors
namespace Better.Commons.EditorAddons.CustomEditors.Attributes
{
/// <summary>
/// <para>Tells an Editor class which run-time type it's an editor for.</para>
Expand Down
3 changes: 3 additions & 0 deletions Editor/CustomEditors/Base.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using UnityEditor;
using UnityEngine;

namespace Better.Commons.EditorAddons.CustomEditors
namespace Better.Commons.EditorAddons.CustomEditors.Base
{
/// <summary>
/// Class represents base types for <see cref="MultiEditor"/>
/// <remarks>Use <see cref="_target"/> and <see cref="_serializedObject"/> as cached fields</remarks>
/// </summary>
public abstract class EditorExtension
public abstract class ExtendedEditor
{
protected readonly Object _target;
protected readonly SerializedObject _serializedObject;

protected EditorExtension(Object target, SerializedObject serializedObject)
protected ExtendedEditor(Object target, SerializedObject serializedObject)
{
_target = target;
_serializedObject = serializedObject;
Expand Down
38 changes: 20 additions & 18 deletions Editor/CustomEditors/MultiEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Better.Commons.EditorAddons.CustomEditors.Attributes;
using Better.Commons.EditorAddons.CustomEditors.Base;
using Better.Commons.EditorAddons.Extensions;
using Better.Commons.Runtime.Extensions;
using UnityEditor;
Expand All @@ -13,8 +15,8 @@ namespace Better.Commons.EditorAddons.CustomEditors
[CustomEditor(typeof(Object), true)]
internal sealed class MultiEditor : Editor
{
private List<EditorExtension> _preExtensions = new List<EditorExtension>();
private List<EditorExtension> _afterExtensions = new List<EditorExtension>();
private List<ExtendedEditor> _preEditors = new List<ExtendedEditor>();
private List<ExtendedEditor> _postEditors = new List<ExtendedEditor>();
private bool _overrideDefault;

private void OnEnable()
Expand Down Expand Up @@ -56,7 +58,7 @@ bool WherePredicate((Type type, MultiEditorAttribute attribute) x)
return att.EditorFor == targetType;
}

return typeof(EditorExtension).GetAllInheritedTypesWithoutUnityObject().Select(type => (type, type.GetCustomAttribute<MultiEditorAttribute>()))
return typeof(ExtendedEditor).GetAllInheritedTypesWithoutUnityObject().Select(type => (type, type.GetCustomAttribute<MultiEditorAttribute>()))
.Where(WherePredicate).OrderBy(x => x.Item2.Order).ToArray();
}

Expand All @@ -75,15 +77,15 @@ private void Iterate(IReadOnlyList<(Type type, MultiEditorAttribute)> extensions
_overrideDefault = true;
}

var extension = (EditorExtension)Activator.CreateInstance(type, paramArray);
var extension = (ExtendedEditor)Activator.CreateInstance(type, paramArray);
extension.OnEnable();
if (betterEditorAttribute.Order < 0)
{
_preExtensions.Add(extension);
_preEditors.Add(extension);
}
else
{
_afterExtensions.Add(extension);
_postEditors.Add(extension);
}
}
}
Expand All @@ -92,44 +94,44 @@ public override void OnInspectorGUI()
{
using (var change = new EditorGUI.ChangeCheckScope())
{
for (var i = 0; i < _preExtensions.Count; i++)
for (var i = 0; i < _preEditors.Count; i++)
{
_preExtensions[i].OnInspectorGUI();
_preEditors[i].OnInspectorGUI();
}

if (!_overrideDefault)
{
base.OnInspectorGUI();
}

for (var i = 0; i < _afterExtensions.Count; i++)
for (var i = 0; i < _postEditors.Count; i++)
{
_afterExtensions[i].OnInspectorGUI();
_postEditors[i].OnInspectorGUI();
}

if (!change.changed) return;
for (var i = 0; i < _preExtensions.Count; i++)
for (var i = 0; i < _preEditors.Count; i++)
{
_preExtensions[i].OnChanged();
_preEditors[i].OnChanged();
}

for (var i = 0; i < _afterExtensions.Count; i++)
for (var i = 0; i < _postEditors.Count; i++)
{
_afterExtensions[i].OnChanged();
_postEditors[i].OnChanged();
}
}
}

private void OnDisable()
{
for (var i = 0; i < _preExtensions.Count; i++)
for (var i = 0; i < _preEditors.Count; i++)
{
_preExtensions[i].OnDisable();
_preEditors[i].OnDisable();
}

for (var i = 0; i < _afterExtensions.Count; i++)
for (var i = 0; i < _postEditors.Count; i++)
{
_afterExtensions[i].OnDisable();
_postEditors[i].OnDisable();
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Editor/Drawers/Base/FieldDrawer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reflection;
using Better.Commons.Runtime.Drawing.Attributes;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.Runtime.Drawers.Attributes;
using UnityEditor;
using UnityEngine;

Expand Down
4 changes: 2 additions & 2 deletions Editor/Drawers/Base/MultiFieldDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.Reflection;
using Better.Commons.EditorAddons.Comparers;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.EditorAddons.Drawers.Utilities;
using Better.Commons.Runtime.Drawing.Attributes;
using Better.Commons.EditorAddons.Drawers.Utility;
using Better.Commons.Runtime.Drawers.Attributes;
using Better.Commons.Runtime.Extensions;
using UnityEditor;

Expand Down
2 changes: 1 addition & 1 deletion Editor/Drawers/Base/WrapperCollection.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using Better.Commons.EditorAddons.Comparers;
using Better.Commons.EditorAddons.Drawers.Utilities;
using Better.Commons.EditorAddons.Drawers.Utility;
using UnityEditor;

namespace Better.Commons.EditorAddons.Drawers.Base
Expand Down
2 changes: 1 addition & 1 deletion Editor/Drawers/Base/WrapperCollectionValue.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Better.Commons.EditorAddons.Drawers.Utilities;
using Better.Commons.EditorAddons.Drawers.Utility;

namespace Better.Commons.EditorAddons.Drawers.Base
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.Runtime.Utility;
using UnityEngine;

namespace Better.Commons.EditorAddons.Drawers.Base
namespace Better.Commons.EditorAddons.Drawers.Caching
{
public class HeightCacheValue : CacheValue<float>
{
Expand Down
2 changes: 1 addition & 1 deletion Editor/Drawers/Caching/ValidateCachedPropertiesUtility.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Better.Commons.EditorAddons.Drawers.Base;
using Better.Commons.EditorAddons.Drawers.Utilities;
using Better.Commons.EditorAddons.Drawers.Utility;
using Better.Commons.Runtime.Utility;
using UnityEditor;

Expand Down
2 changes: 1 addition & 1 deletion Editor/Drawers/MultiPropertyDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Better.Commons.EditorAddons.Drawers.Attributes;
using Better.Commons.EditorAddons.Drawers.Base;
using Better.Commons.Runtime.Comparers;
using Better.Commons.Runtime.Drawing.Attributes;
using Better.Commons.Runtime.Drawers.Attributes;
using Better.Commons.Runtime.Extensions;
using Better.Internal.Core.Runtime;
using UnityEditor;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Better.Commons.Runtime.Utility;
using UnityEditor;

namespace Better.Commons.EditorAddons.Drawers.Utilities
namespace Better.Commons.EditorAddons.Drawers.Utility
{
public abstract class BaseUtility<THandler> where THandler : new()
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Better.Commons.EditorAddons.Drawers.Utilities
namespace Better.Commons.EditorAddons.Drawers.Utility
{
public abstract class UtilityWrapper
{
Expand Down
3 changes: 3 additions & 0 deletions Editor/DropDown/Base.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using UnityEngine;

namespace Better.Commons.EditorAddons.DropDown
namespace Better.Commons.EditorAddons.DropDown.Base
{
public abstract class DropdownBase
{
Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion Editor/DropDown/DropdownCollection.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Better.Commons.EditorAddons.DropDown.Base;
using Better.Commons.EditorAddons.Enums;
using Better.Commons.EditorAddons.Extensions;
using Better.Commons.EditorAddons.Utility;
using Better.Commons.Runtime.DataStructures.Tree;
using Better.Commons.Runtime.Utility;
Expand Down Expand Up @@ -77,7 +80,7 @@ private static TreeNode<DropdownBase> AddLeaf(TreeNode<DropdownBase> item, GUICo
{
if (bufferKey.image == null && state)
{
bufferKey.image = DrawersUtility.GetIcon(IconType.Checkmark);
bufferKey.image = IconType.Checkmark.GetIcon();
}
return item.AddChild(new DropdownItem(bufferKey, onSelect, type));
}
Expand Down
1 change: 1 addition & 0 deletions Editor/DropDown/DropdownItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Better.Commons.EditorAddons.DropDown.Base;
using UnityEngine;

namespace Better.Commons.EditorAddons.DropDown
Expand Down
3 changes: 2 additions & 1 deletion Editor/DropDown/DropdownSubTree.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Better.Commons.Runtime.DataStructures.Tree;
using Better.Commons.EditorAddons.DropDown.Base;
using Better.Commons.Runtime.DataStructures.Tree;
using UnityEngine;

namespace Better.Commons.EditorAddons.DropDown
Expand Down
11 changes: 6 additions & 5 deletions Editor/DropDown/DropdownWindow.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Better.Commons.EditorAddons.DropDown.Base;
using Better.Commons.EditorAddons.Helpers;
using Better.Commons.EditorAddons.Utility;
using Better.Commons.Runtime.DataStructures.Tree;
Expand Down Expand Up @@ -70,11 +71,11 @@ private void OnLostFocus()
private void OnGUI()
{
EditorGUILayout.BeginVertical();
_searchText = DropdownGUI.DrawSearchField(_searchText, false);
_searchText = DropdownUtility.DrawSearchField(_searchText, false);
var buffer = SearchResult(_currentNode, _searchText);

var hasParent = _currentNode.Parent != null;
DropdownGUI.DrawHeader(hasParent ? _currentNode.Value.Content : _header,
DropdownUtility.DrawHeader(hasParent ? _currentNode.Value.Content : _header,
hasParent, OnBackClicked);
var close = AnalyseUserInput(buffer);
if (!close)
Expand Down Expand Up @@ -128,7 +129,7 @@ private bool DrawItems(List<TreeNode<DropdownBase>> buffer, GUIStyle buttonStyle
{
var bufferContent = item.Value.Content;
size = Vector2.Max(buttonStyle.CalcSize(bufferContent), size);
if (DropdownGUI.DrawItem(item, item.Children.Count > 0, true))
if (DropdownUtility.DrawItem(item, item.Children.Count > 0, true))
shouldClose = item.Value.Invoke(this);
}

Expand Down Expand Up @@ -194,15 +195,15 @@ private bool CaseEscape()
}

_searchText = string.Empty;
DropdownGUI.ClearSearchField();
DropdownUtility.ClearSearchField();

return false;
}

private void ResolveSize(Vector2 size)
{
var width = Mathf.Max(position.width, size.x + 50f);
var height = UnityEditor.EditorGUIUtility.singleLineHeight * _maxLines + DrawersUtility.SpaceHeight;
var height = UnityEditor.EditorGUIUtility.singleLineHeight * _maxLines + ExtendedGUIUtility.SpaceHeight;
var copy = position;
copy.position = _display;
copy.width = width;
Expand Down
3 changes: 1 addition & 2 deletions Editor/EditorPopups/EditorPopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public class EditorPopup : EditorWindow
public event Action FocusLost;
public event Action Destroyed;

public static EditorPopup Initialize(Texture texture, Rect position, bool needUpdate,
bool destroyTexture = false)
public static EditorPopup Initialize(Texture texture, Rect position, bool needUpdate, bool destroyTexture = false)
{
var window = HasOpenInstances<EditorPopup>() ? GetWindow<EditorPopup>() : CreateInstance<EditorPopup>();
window.position = position;
Expand Down
3 changes: 3 additions & 0 deletions Editor/Enums.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Editor/Enums/IconType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Better.Commons.EditorAddons.Enums
{
public enum IconType
{
None,
InfoMessage,
WarningMessage,
ErrorMessage,
Info,
View,
Close,
Search,
WhiteLine,
GrayLine,
WhiteDropdown,
GrayDropdown,
Checkmark,
GrayPlayButton,
PlusMore,
Minus
}
}
File renamed without changes.
Loading

0 comments on commit 1ce2be2

Please sign in to comment.