diff --git a/Assets/BetterValidation/Editor/EditorAddons/Drawers/ValidationDrawer.cs b/Assets/BetterValidation/Editor/EditorAddons/Drawers/ValidationDrawer.cs index 28812eb..ce5434d 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Drawers/ValidationDrawer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Drawers/ValidationDrawer.cs @@ -15,7 +15,7 @@ namespace Better.Validation.EditorAddons.Drawers [MultiCustomPropertyDrawer(typeof(ValidationAttribute))] public class ValidationDrawer : MultiFieldDrawer { - private Cache> _validationResult = new Cache>(); + private Cache> _validationResult = new Cache>(); public ValidationDrawer(FieldInfo fieldInfo, MultiPropertyAttribute attribute) : base(fieldInfo, attribute) { @@ -39,7 +39,7 @@ protected override bool PreDraw(ref Rect position, SerializedProperty property, if (wrapper.IsSupported()) { var validation = wrapper.Validate(); - _validationResult.Set(validation.IsValid, new BetterTuple(validation.Value, wrapper.Type)); + _validationResult.Set(validation.IsValid, new MutableTuple(validation.Value, wrapper.Type)); } return true; diff --git a/Assets/BetterValidation/Editor/EditorAddons/Iteration/Iterator.cs b/Assets/BetterValidation/Editor/EditorAddons/Iteration/Iterator.cs index 588110f..eea12dd 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Iteration/Iterator.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Iteration/Iterator.cs @@ -46,15 +46,15 @@ public static List ObjectIteration(Object go, OnPropertyI var so = new SerializedObject(obj); CacheData.SetContext(so); - so.forceChildVisibility = true; + //so.forceChildVisibility = true; so.Update(); var sp = so.GetIterator(); var copy = sp.Copy(); - if (copy.NextVisible(true)) + if (copy.Next(true)) { var count = copy.CountInProperty(); - while (sp.NextVisible(true)) + while (sp.Next(true)) { var remainingCopy = sp.Copy(); EditorUtility.DisplayProgressBar("Validating property...", $"Validating {sp.propertyPath}...", diff --git a/Assets/BetterValidation/Editor/EditorAddons/BetterTuple.cs b/Assets/BetterValidation/Editor/EditorAddons/MutableTuple.cs similarity index 79% rename from Assets/BetterValidation/Editor/EditorAddons/BetterTuple.cs rename to Assets/BetterValidation/Editor/EditorAddons/MutableTuple.cs index 87ff0c2..b0c272c 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/BetterTuple.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/MutableTuple.cs @@ -1,14 +1,14 @@ namespace Better.Validation.EditorAddons { - public class BetterTuple + public class MutableTuple { - public BetterTuple(T1 item1, T2 item2) + public MutableTuple(T1 item1, T2 item2) { Item1 = item1; Item2 = item2; } - public BetterTuple() + public MutableTuple() { Item1 = default; Item2 = default; diff --git a/Assets/BetterValidation/Editor/EditorAddons/BetterTuple.cs.meta b/Assets/BetterValidation/Editor/EditorAddons/MutableTuple.cs.meta similarity index 54% rename from Assets/BetterValidation/Editor/EditorAddons/BetterTuple.cs.meta rename to Assets/BetterValidation/Editor/EditorAddons/MutableTuple.cs.meta index d50c313..7976879 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/BetterTuple.cs.meta +++ b/Assets/BetterValidation/Editor/EditorAddons/MutableTuple.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: d6a2ff216fb941a297820153127c4ce8 +guid: 38ae0c80495986e4a98432b2a88ac072 timeCreated: 1687267697 \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs b/Assets/BetterValidation/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs index 76247af..a58a4c4 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs @@ -33,9 +33,6 @@ public static class ToolsGUIUtility margin = new RectOffset() }; - public static GUIStyle _overridesHoverHighlight = "HoverHighlight"; - public static GUIStyle _hoveredItemBackgroundStyle = "WhiteBackground"; - public static int Toolbar(int groupID, string[] groupNames, out bool changed) { var id = GUILayout.Toolbar(groupID, groupNames); @@ -43,26 +40,6 @@ public static int Toolbar(int groupID, string[] groupNames, out bool changed) return id; } - public static void DrawHorizontalLine(Color color, int thickness = 2, int padding = 10) - { - Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(padding + thickness)); - r.height = thickness; - r.y += padding / 2f; - r.x -= 2; - r.width += 6; - EditorGUI.DrawRect(r, color); - } - - public static void DrawVerticalLine(Color color, int thickness = 1, int padding = 10) - { - Rect r = EditorGUILayout.GetControlRect(GUILayout.Width(padding + thickness)); - r.width = thickness; - r.x += padding / 2f; - r.y -= 2; - r.height += 6f; - EditorGUI.DrawRect(r, color); - } - private static void DrawVerticalLineFull(Color color, int thickness = 1, int padding = 10) { Rect r = EditorGUILayout.GetControlRect(GUILayout.Width(padding + thickness)); diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationExtensions.cs b/Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationExtensions.cs index ac1b4e0..f01598c 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationExtensions.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using Better.EditorTools.Helpers; using Better.Validation.Runtime.Attributes; using UnityEditor; @@ -7,6 +8,12 @@ using UnityEngine; using UnityEngine.SceneManagement; using System.Linq; +using Better.Extensions.Runtime; + +#if !UNITY_2021_2_OR_NEWER +using UnityEditor.Experimental.SceneManagement; +#endif + namespace Better.Validation.EditorAddons.Utilities { @@ -30,9 +37,20 @@ public static void OpenReference(UnityEngine.Object reference) var transform = component.transform; if (PrefabUtility.IsPartOfPrefabAsset(reference)) { - var stage = PrefabStageUtility.OpenPrefab(AssetDatabase.GetAssetPath(reference)); + var assetPath = AssetDatabase.GetAssetPath(reference); + Transform prefabRootTransform = null; +#if !UNITY_2021_2_OR_NEWER + var obj = AssetDatabase.LoadAssetAtPath(assetPath); + AssetDatabase.OpenAsset(obj); + var stage = PrefabStageUtility.GetCurrentPrefabStage(); + prefabRootTransform = stage.prefabContentsRoot.transform; +#else + var stage = PrefabStageUtility.OpenPrefab(assetPath); + prefabRootTransform = stage.prefabContentsRoot.transform; +#endif var indexes = GetParentIndices(transform); - transform = GetChildBySiblingIndices(stage.prefabContentsRoot.transform, indexes); + + transform = GetChildBySiblingIndices(prefabRootTransform, indexes); } else { diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/CollectionDrawer.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/CollectionDrawer.cs index 997d8e3..0bfbc91 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/CollectionDrawer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/CollectionDrawer.cs @@ -64,14 +64,15 @@ protected virtual void DrawLabel(ValidationCommandData data) { var reference = data.Target; - var icon = EditorGUIUtility.GetIconForObject(reference); var csIcon = EditorGUIUtility.IconContent("cs Script Icon"); csIcon.text = reference.GetType().Name; +#if UNITY_2021_2_OR_NEWER + var icon = EditorGUIUtility.GetIconForObject(reference); if (icon) { csIcon.image = icon; } - +#endif EditorGUILayout.LabelField(csIcon); EditorGUILayout.Space(DrawersHelper.SpaceHeight); diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/GroupDictionaryDrawer.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/GroupDictionaryDrawer.cs index f408f04..1c12850 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/GroupDictionaryDrawer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/GroupDictionaryDrawer.cs @@ -6,7 +6,7 @@ namespace Better.Validation.EditorAddons.WindowModule.CollectionDrawing { - public abstract class GroupDictionaryDrawer : CollectionDrawer where TDictionary: class, IDictionary>> + public abstract class GroupDictionaryDrawer : CollectionDrawer where TDictionary: class, IDictionary>> { protected TDictionary _dataDictionary = null; protected int _count; diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/ObjectGroupDrawer.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/ObjectGroupDrawer.cs index fc5a3cf..1d01f30 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/ObjectGroupDrawer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/ObjectGroupDrawer.cs @@ -4,7 +4,7 @@ namespace Better.Validation.EditorAddons.WindowModule.CollectionDrawing { - public class ObjectGroupDrawer : GroupDictionaryDrawer>>> + public class ObjectGroupDrawer : GroupDictionaryDrawer>>> { public override int Order { get; } = 2; @@ -15,12 +15,12 @@ public override string GetOptionName() public override CollectionDrawer Initialize(List data) { - _dataDictionary = new Dictionary>>(GameObjectGroupingComparer.Instance); + _dataDictionary = new Dictionary>>(GameObjectGroupingComparer.Instance); foreach (var commandData in data) { if (!_dataDictionary.TryGetValue(commandData.Target, out var list)) { - list = new BetterTuple>(true, new List()); + list = new MutableTuple>(true, new List()); _dataDictionary.Add(commandData.Target, list); } diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/TypeGroupDrawer.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/TypeGroupDrawer.cs index 4341fce..92e5d33 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/TypeGroupDrawer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/TypeGroupDrawer.cs @@ -4,7 +4,7 @@ namespace Better.Validation.EditorAddons.WindowModule.CollectionDrawing { - public class TypeGroupDrawer : GroupDictionaryDrawer>>> + public class TypeGroupDrawer : GroupDictionaryDrawer>>> { public override int Order { get; } = 1; @@ -16,13 +16,13 @@ public override string GetOptionName() public override CollectionDrawer Initialize(List data) { _dataDictionary = - new SortedDictionary>>(Comparer.Create((x, y) => y.CompareTo(x))); + new SortedDictionary>>(Comparer.Create((x, y) => y.CompareTo(x))); foreach (var commandData in data) { var iconType = commandData.Type; if (!_dataDictionary.TryGetValue(iconType, out var list)) { - list = new BetterTuple>(iconType == ValidationType.Error || commandData == _currentItem, + list = new MutableTuple>(iconType == ValidationType.Error || commandData == _currentItem, new List()); _dataDictionary.Add(iconType, list); } diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/ResultPage.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/ResultPage.cs index 377997a..89392c6 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/ResultPage.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/ResultPage.cs @@ -10,6 +10,10 @@ using UnityEngine; using UnityEngine.SceneManagement; +#if !UNITY_2021_1_OR_NEWER +using UnityEditor.Experimental.SceneManagement; +#endif + namespace Better.Validation.EditorAddons.WindowModule.Pages { public class ResultPage : IWindowPage diff --git a/Assets/BetterValidation/package.json b/Assets/BetterValidation/package.json index a3720db..96af0a9 100644 --- a/Assets/BetterValidation/package.json +++ b/Assets/BetterValidation/package.json @@ -1,7 +1,7 @@ { "name": "com.uurha.bettervalidation", "displayName": "Better Validation", - "version": "1.0.53", + "version": "1.0.54", "unity": "2020.1", "description": " ", "dependencies": {