diff --git a/Editor/EditorAddons/Drawers/ValidationDrawer.cs b/Editor/EditorAddons/Drawers/ValidationDrawer.cs index 2e43d59..28812eb 100644 --- a/Editor/EditorAddons/Drawers/ValidationDrawer.cs +++ b/Editor/EditorAddons/Drawers/ValidationDrawer.cs @@ -5,7 +5,7 @@ using Better.EditorTools.Helpers.Caching; using Better.Tools.Runtime.Attributes; using Better.Validation.EditorAddons.Utilities; -using Better.Validation.EditorAddons.ValidationWrappers; +using Better.Validation.EditorAddons.Wrappers; using Better.Validation.Runtime.Attributes; using UnityEditor; using UnityEngine; diff --git a/Editor/EditorAddons/Iteration.meta b/Editor/EditorAddons/Iteration.meta new file mode 100644 index 0000000..2f1e5b5 --- /dev/null +++ b/Editor/EditorAddons/Iteration.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b0306308f50e4aaa824953a427710f1e +timeCreated: 1689115992 \ No newline at end of file diff --git a/Editor/EditorAddons/Utilities/IterationData.cs b/Editor/EditorAddons/Iteration/IterationData.cs similarity index 94% rename from Editor/EditorAddons/Utilities/IterationData.cs rename to Editor/EditorAddons/Iteration/IterationData.cs index 09d5b63..b22d7b7 100644 --- a/Editor/EditorAddons/Utilities/IterationData.cs +++ b/Editor/EditorAddons/Iteration/IterationData.cs @@ -2,7 +2,7 @@ using UnityEditor; using UnityEngine; -namespace Better.Validation.EditorAddons.Utilities +namespace Better.Validation.EditorAddons.Iteration { public class IterationData { diff --git a/Editor/EditorAddons/Utilities/IterationData.cs.meta b/Editor/EditorAddons/Iteration/IterationData.cs.meta similarity index 100% rename from Editor/EditorAddons/Utilities/IterationData.cs.meta rename to Editor/EditorAddons/Iteration/IterationData.cs.meta diff --git a/Editor/EditorAddons/Utilities/Iterator.cs b/Editor/EditorAddons/Iteration/Iterator.cs similarity index 96% rename from Editor/EditorAddons/Utilities/Iterator.cs rename to Editor/EditorAddons/Iteration/Iterator.cs index 6d2c3bc..588110f 100644 --- a/Editor/EditorAddons/Utilities/Iterator.cs +++ b/Editor/EditorAddons/Iteration/Iterator.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; -using System.Threading.Tasks; using Better.Validation.EditorAddons.ContextResolver; -using Better.Validation.EditorAddons.ValidationWrappers; +using Better.Validation.EditorAddons.Utilities; +using Better.Validation.EditorAddons.Wrappers; using UnityEditor; using UnityEngine; -namespace Better.Validation.EditorAddons.Utilities +namespace Better.Validation.EditorAddons.Iteration { public static class Iterator { diff --git a/Editor/EditorAddons/Utilities/Iterator.cs.meta b/Editor/EditorAddons/Iteration/Iterator.cs.meta similarity index 100% rename from Editor/EditorAddons/Utilities/Iterator.cs.meta rename to Editor/EditorAddons/Iteration/Iterator.cs.meta diff --git a/Editor/EditorAddons/Utilities/IteratorFilter.cs b/Editor/EditorAddons/Iteration/IteratorFilter.cs similarity index 96% rename from Editor/EditorAddons/Utilities/IteratorFilter.cs rename to Editor/EditorAddons/Iteration/IteratorFilter.cs index 89036aa..0ebe6e5 100644 --- a/Editor/EditorAddons/Utilities/IteratorFilter.cs +++ b/Editor/EditorAddons/Iteration/IteratorFilter.cs @@ -3,10 +3,11 @@ using Better.EditorTools.Drawers.Base; using Better.EditorTools.Helpers.Caching; using Better.Extensions.Runtime; -using Better.Validation.EditorAddons.ValidationWrappers; +using Better.Validation.EditorAddons.Utilities; +using Better.Validation.EditorAddons.Wrappers; using Better.Validation.Runtime.Attributes; -namespace Better.Validation.EditorAddons.Utilities +namespace Better.Validation.EditorAddons.Iteration { public static class IteratorFilter { diff --git a/Editor/EditorAddons/Utilities/IteratorFilter.cs.meta b/Editor/EditorAddons/Iteration/IteratorFilter.cs.meta similarity index 100% rename from Editor/EditorAddons/Utilities/IteratorFilter.cs.meta rename to Editor/EditorAddons/Iteration/IteratorFilter.cs.meta diff --git a/Editor/EditorAddons/PreBuildValidation.meta b/Editor/EditorAddons/PreBuildValidation.meta new file mode 100644 index 0000000..c2335a4 --- /dev/null +++ b/Editor/EditorAddons/PreBuildValidation.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9b0758df1e37463d90637dbc6a9dad1e +timeCreated: 1689717156 \ No newline at end of file diff --git a/Editor/EditorAddons/PreBuildValidation/Interfaces.meta b/Editor/EditorAddons/PreBuildValidation/Interfaces.meta new file mode 100644 index 0000000..0bcf775 --- /dev/null +++ b/Editor/EditorAddons/PreBuildValidation/Interfaces.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b8d7d298e777454ab14ad1a738aa5095 +timeCreated: 1689717898 \ No newline at end of file diff --git a/Editor/EditorAddons/PreBuildValidation/Interfaces/IBuildValidationStep.cs b/Editor/EditorAddons/PreBuildValidation/Interfaces/IBuildValidationStep.cs new file mode 100644 index 0000000..14222cc --- /dev/null +++ b/Editor/EditorAddons/PreBuildValidation/Interfaces/IBuildValidationStep.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Better.Validation.EditorAddons.PreBuildValidation.Interfaces +{ + public interface IBuildValidationStep + { + public List GatherValidationData(); + } +} \ No newline at end of file diff --git a/Editor/EditorAddons/PreBuildValidation/Interfaces/IBuildValidationStep.cs.meta b/Editor/EditorAddons/PreBuildValidation/Interfaces/IBuildValidationStep.cs.meta new file mode 100644 index 0000000..2cc510b --- /dev/null +++ b/Editor/EditorAddons/PreBuildValidation/Interfaces/IBuildValidationStep.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fd597c09c2a34d06bbef5995616410c9 +timeCreated: 1689717930 \ No newline at end of file diff --git a/Editor/EditorAddons/PreBuildValidation/Models.meta b/Editor/EditorAddons/PreBuildValidation/Models.meta new file mode 100644 index 0000000..758fb2d --- /dev/null +++ b/Editor/EditorAddons/PreBuildValidation/Models.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 780df3e63d7f4e2e85fcba3982b52dfb +timeCreated: 1689718210 \ No newline at end of file diff --git a/Editor/EditorAddons/PreBuildValidation/Models/ProjectValidationStep.cs b/Editor/EditorAddons/PreBuildValidation/Models/ProjectValidationStep.cs new file mode 100644 index 0000000..ec180e1 --- /dev/null +++ b/Editor/EditorAddons/PreBuildValidation/Models/ProjectValidationStep.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using Better.Validation.EditorAddons.PreBuildValidation.Interfaces; + +namespace Better.Validation.EditorAddons.PreBuildValidation.Models +{ + [Serializable] + public class ProjectValidationStep : IBuildValidationStep + { + public List GatherValidationData() + { + var commands = new ValidatorCommands(); + return commands.ValidateAttributesInProject(); + } + } + + [Serializable] + public class AllSceneValidationStep : IBuildValidationStep + { + public List GatherValidationData() + { + var commands = new ValidatorCommands(); + return commands.ValidateAttributesInAllScenes(); + } + } +} \ No newline at end of file diff --git a/Editor/EditorAddons/PreBuildValidation/Models/ProjectValidationStep.cs.meta b/Editor/EditorAddons/PreBuildValidation/Models/ProjectValidationStep.cs.meta new file mode 100644 index 0000000..fcfee39 --- /dev/null +++ b/Editor/EditorAddons/PreBuildValidation/Models/ProjectValidationStep.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b58d6709b1ad43f9bb9e6bbffa2e750c +timeCreated: 1689718655 \ No newline at end of file diff --git a/Editor/EditorAddons/Utilities/ValidationBuildProcess.cs b/Editor/EditorAddons/PreBuildValidation/ValidationBuildProcess.cs similarity index 80% rename from Editor/EditorAddons/Utilities/ValidationBuildProcess.cs rename to Editor/EditorAddons/PreBuildValidation/ValidationBuildProcess.cs index 14bdea5..b4c1406 100644 --- a/Editor/EditorAddons/Utilities/ValidationBuildProcess.cs +++ b/Editor/EditorAddons/PreBuildValidation/ValidationBuildProcess.cs @@ -11,25 +11,28 @@ using UnityEditor.Build.Reporting; using UnityEngine; -namespace Better.Validation.EditorAddons.Utilities +namespace Better.Validation.EditorAddons.PreBuildValidation { public class ValidationBuildProcess : IPreprocessBuildWithReport { - private readonly BetterValidationSettings _settings; + private readonly ValidationSettings _settings; public int callbackOrder { get; } public ValidationBuildProcess() { - _settings = Resources.Load(nameof(BetterValidationSettings)); + _settings = Resources.Load(nameof(ValidationSettings)); } public void OnPreprocessBuild(BuildReport report) { if(_settings.DisableBuildValidation) return; - var commands = new ValidatorCommands(); var commandDatas = new List(); - commandDatas.AddRange(commands.ValidateAttributesInProject()); - commandDatas.AddRange(commands.ValidateAttributesInAllScenes()); + + var validationSteps = _settings.GetSteps(); + foreach (var buildValidationStep in validationSteps) + { + commandDatas.AddRange(buildValidationStep.GatherValidationData()); + } commandDatas = commandDatas.Where(x => x.Type >= _settings.BuildLoggingLevel).ToList(); if (!commandDatas.Any()) return; @@ -50,7 +53,7 @@ public void OnPreprocessBuild(BuildReport report) str.AppendLine("Do you want to ignore those issues?"); str.Append(Environment.NewLine); str.Append(Environment.NewLine); - str.AppendFormat("(You can disable validation in Edit > Project Settings > {0} > {1})", ProjectSettingsRegisterer.BetterPrefix, ValidationSettingsTool.SettingMenuItem); + str.AppendFormat("(You can disable validation in Edit > Project Settings > {0} > {1})", ProjectSettingsRegisterer.BetterPrefix, ProjectSettingsToolsContainer.Instance.NamespacePrefix); EditorApplication.Beep(); if (!EditorUtility.DisplayDialog("Validation failed", str.ToString(), "Ignore", "Resolve")) { diff --git a/Editor/EditorAddons/Utilities/ValidationBuildProcess.cs.meta b/Editor/EditorAddons/PreBuildValidation/ValidationBuildProcess.cs.meta similarity index 100% rename from Editor/EditorAddons/Utilities/ValidationBuildProcess.cs.meta rename to Editor/EditorAddons/PreBuildValidation/ValidationBuildProcess.cs.meta diff --git a/Editor/EditorAddons/Settings/BetterValidationSettings.cs b/Editor/EditorAddons/Settings/BetterValidationSettings.cs deleted file mode 100644 index 897b058..0000000 --- a/Editor/EditorAddons/Settings/BetterValidationSettings.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Better.Tools.Runtime.Settings; -using Better.Validation.Runtime.Attributes; -using UnityEngine; - -namespace Better.Validation.EditorAddons.Settings -{ - public class BetterValidationSettings : ProjectSettings - { - [SerializeField] private bool disableBuildValidation; - [SerializeField] private ValidationType buildLoggingLevel = ValidationType.Warning; - - public ValidationType BuildLoggingLevel => buildLoggingLevel; - - public bool DisableBuildValidation => disableBuildValidation; - } -} \ No newline at end of file diff --git a/Editor/EditorAddons/Settings/BuildValidationStepsDrawer.cs b/Editor/EditorAddons/Settings/BuildValidationStepsDrawer.cs new file mode 100644 index 0000000..88107c0 --- /dev/null +++ b/Editor/EditorAddons/Settings/BuildValidationStepsDrawer.cs @@ -0,0 +1,136 @@ +using System; +using Better.EditorTools; +using Better.EditorTools.Helpers; +using Better.EditorTools.Helpers.DropDown; +using Better.Extensions.Runtime; +using Better.Validation.EditorAddons.PreBuildValidation.Interfaces; +using UnityEditor; +using UnityEditorInternal; +using UnityEngine; + +namespace Better.Validation.EditorAddons.Settings +{ + internal class BuildValidationStepsDrawer + { + private readonly Type[] _types; + private readonly ReorderableList _reorderableList; + private readonly SerializedProperty _stepsProperty; + private readonly GUIContent _popupHeader = new GUIContent("Build Steps"); + private readonly GUIContent _validationStepsLabel = new GUIContent("Validation Steps"); + private readonly GUIContent _rootContent = new GUIContent("Root"); + private const string NullName = "null"; + + public BuildValidationStepsDrawer(SerializedObject settingsObject, SerializedProperty stepsProperty) + { + _types = typeof(IBuildValidationStep).GetAllInheritedType(); + _stepsProperty = stepsProperty; + + _reorderableList = new ReorderableList(settingsObject, _stepsProperty, true, true, true, true) + { + drawElementCallback = DrawElementCallback, + drawHeaderCallback = HeaderCallback, + elementHeightCallback = ElementHeightCallback + }; + } + + private float ElementHeightCallback(int index) + { + var property = _stepsProperty.GetArrayElementAtIndex(index); + return EditorGUI.GetPropertyHeight(property, true); + } + + private void HeaderCallback(Rect rect) + { + EditorGUI.LabelField(rect, _validationStepsLabel); + } + + private void DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused) + { + + var property = _stepsProperty.GetArrayElementAtIndex(index); + + var type = property.GetManagedType(); + DrawButton(rect, property, type); + var label = new GUIContent(L10n.Tr($"Element {index.ToString()}")); + EditorGUI.PropertyField(rect, property, label, true); + } + + private void DrawButton(Rect rect, SerializedProperty serializedProperty, Type currentValue) + { + var typeName = currentValue == null ? NullName : currentValue.Name; + var content = DrawersHelper.GetIconGUIContent(IconType.GrayDropdown); + content.text = typeName; + var buttonPosition = GetPopupPosition(rect); + if (GUI.Button(buttonPosition, content, Styles.Button)) + { + ShowDropDown(buttonPosition, serializedProperty, currentValue); + } + } + + private void ShowDropDown(Rect popupPosition, SerializedProperty serializedProperty, Type currentValue) + { + var copy = popupPosition; + copy.y += EditorGUIUtility.singleLineHeight; + + var popup = DropdownWindow.ShowWindow(GUIUtility.GUIToScreenRect(copy), _popupHeader); + var items = GenerateItemsTree(serializedProperty, currentValue); + + popup.SetItems(items); + } + + private DropdownCollection GenerateItemsTree(SerializedProperty serializedProperty, Type currentValue) + { + var collection = new DropdownCollection(new DropdownSubTree(_rootContent)); + foreach (var type in _types) + { + var typeName = type == null ? NullName : type.Name; + var guiContent = new GUIContent(typeName); + if (guiContent.image == null && type == currentValue) + { + guiContent.image = DrawersHelper.GetIcon(IconType.Checkmark); + } + + var item = new DropdownItem(guiContent, OnSelectItem, new Tuple(serializedProperty, type)); + collection.AddChild(item); + } + + return collection; + } + + private static void OnSelectItem(object obj) + { + if (obj is Tuple(var serializedProperty, var type)) + { + if (!serializedProperty.Verify()) return; + serializedProperty.managedReferenceValue = type == null ? null : Activator.CreateInstance(type); + + var serializedObject = serializedProperty.serializedObject; + EditorUtility.SetDirty(serializedObject.targetObject); + serializedObject.ApplyModifiedProperties(); + } + } + + private static Rect GetPopupPosition(Rect currentPosition) + { + var popupPosition = new Rect(currentPosition); + popupPosition.width -= EditorGUIUtility.labelWidth; + popupPosition.x += EditorGUIUtility.labelWidth; + popupPosition.height = EditorGUIUtility.singleLineHeight; + return popupPosition; + } + + public void DoLayoutList() + { + using (var scope = new EditorGUI.ChangeCheckScope()) + { + _reorderableList.DoLayoutList(); + if (scope.changed) + { + var serializedObject = _stepsProperty.serializedObject; + EditorUtility.SetDirty(serializedObject.targetObject); + serializedObject.ApplyModifiedProperties(); + } + } + } + } +} \ No newline at end of file diff --git a/Editor/EditorAddons/Settings/BuildValidationStepsDrawer.cs.meta b/Editor/EditorAddons/Settings/BuildValidationStepsDrawer.cs.meta new file mode 100644 index 0000000..47c5284 --- /dev/null +++ b/Editor/EditorAddons/Settings/BuildValidationStepsDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 313d6487459c4d5c846ad3cdaa98f9d7 +timeCreated: 1689901907 \ No newline at end of file diff --git a/Editor/EditorAddons/Settings/ValidationSettingProvider.cs b/Editor/EditorAddons/Settings/ValidationSettingProvider.cs index 63e9f8a..33bccbd 100644 --- a/Editor/EditorAddons/Settings/ValidationSettingProvider.cs +++ b/Editor/EditorAddons/Settings/ValidationSettingProvider.cs @@ -4,11 +4,14 @@ namespace Better.Validation.EditorAddons.Settings { - internal class ValidationSettingProvider : ProjectSettingsProvider + internal class ValidationSettingProvider : ProjectSettingsProvider { + private readonly Editor _editor; + public ValidationSettingProvider() : base(ProjectSettingsToolsContainer.Instance, SettingsScope.Project) { keywords = new HashSet(new[] { "Better", "Validation", "Warnings", "Ignore" }); + _editor = Editor.CreateEditor(_settings); } [MenuItem(ValidationSettingsTool.MenuItemPrefix + "/" + ProjectSettingsRegisterer.HighlightPrefix, false, 999)] @@ -19,8 +22,7 @@ private static void Highlight() protected override void DrawGUI() { - EditorGUILayout.PropertyField(_settingsObject.FindProperty("disableBuildValidation")); - EditorGUILayout.PropertyField(_settingsObject.FindProperty("buildLoggingLevel")); + _editor.OnInspectorGUI(); } } } \ No newline at end of file diff --git a/Editor/EditorAddons/Settings/ValidationSettings.cs b/Editor/EditorAddons/Settings/ValidationSettings.cs new file mode 100644 index 0000000..0db41ad --- /dev/null +++ b/Editor/EditorAddons/Settings/ValidationSettings.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using Better.Tools.Runtime.Settings; +using Better.Validation.EditorAddons.PreBuildValidation.Interfaces; +using Better.Validation.EditorAddons.PreBuildValidation.Models; +using Better.Validation.Runtime.Attributes; +using UnityEngine; + +namespace Better.Validation.EditorAddons.Settings +{ + public class ValidationSettings : ProjectSettings + { + [SerializeField] private bool disableBuildValidation; + [SerializeField] private ValidationType buildLoggingLevel = ValidationType.Warning; + + [SerializeReference] private IBuildValidationStep[] validationSteps = new IBuildValidationStep[] + { new ProjectValidationStep(), new AllSceneValidationStep() }; + + public ValidationType BuildLoggingLevel => buildLoggingLevel; + + public bool DisableBuildValidation => disableBuildValidation; + + public List GetSteps() + { + return new List(validationSteps); + } + } +} \ No newline at end of file diff --git a/Editor/EditorAddons/Settings/BetterValidationSettings.cs.meta b/Editor/EditorAddons/Settings/ValidationSettings.cs.meta similarity index 100% rename from Editor/EditorAddons/Settings/BetterValidationSettings.cs.meta rename to Editor/EditorAddons/Settings/ValidationSettings.cs.meta diff --git a/Editor/EditorAddons/Settings/ValidationSettingsEditor.cs b/Editor/EditorAddons/Settings/ValidationSettingsEditor.cs new file mode 100644 index 0000000..1630f1f --- /dev/null +++ b/Editor/EditorAddons/Settings/ValidationSettingsEditor.cs @@ -0,0 +1,51 @@ +using System; +using Better.EditorTools.Helpers; +using UnityEditor; +using UnityEditorInternal; +using Object = UnityEngine.Object; + +namespace Better.Validation.EditorAddons.Settings +{ + [CustomEditor(typeof(ValidationSettings))] + public class ValidationSettingsEditor : Editor + { + private SerializedProperty _disableBuildProperty; + private SerializedProperty _logLevelProperty; + private BuildValidationStepsDrawer _drawer; + private SerializedProperty _stepsProperty; + private Object _target; + + private void OnEnable() + { + _disableBuildProperty = serializedObject.FindProperty("disableBuildValidation"); + _logLevelProperty = serializedObject.FindProperty("buildLoggingLevel"); + _stepsProperty = serializedObject.FindProperty("validationSteps"); + _drawer = new BuildValidationStepsDrawer(serializedObject, _stepsProperty); + _target = serializedObject.targetObject; + } + + public override bool RequiresConstantRepaint() + { + return EditorUtility.IsDirty(_target); + } + + public override void OnInspectorGUI() + { + using(var scope = new EditorGUI.ChangeCheckScope()) + { + if(EditorUtility.IsDirty(_target)) + { + serializedObject.Update(); + serializedObject.ApplyModifiedProperties(); + } + EditorGUILayout.PropertyField(_disableBuildProperty); + EditorGUILayout.PropertyField(_logLevelProperty); + _drawer.DoLayoutList(); + if (scope.changed) + { + EditorUtility.SetDirty(_target); + } + } + } + } +} \ No newline at end of file diff --git a/Editor/EditorAddons/Settings/ValidationSettingsEditor.cs.meta b/Editor/EditorAddons/Settings/ValidationSettingsEditor.cs.meta new file mode 100644 index 0000000..d35664d --- /dev/null +++ b/Editor/EditorAddons/Settings/ValidationSettingsEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7c878cf2f74a4b03ac8daef3b4dda63e +timeCreated: 1689902459 \ No newline at end of file diff --git a/Editor/EditorAddons/Settings/ValidationSettingsTool.cs b/Editor/EditorAddons/Settings/ValidationSettingsTool.cs index f3d7585..4a3f685 100644 --- a/Editor/EditorAddons/Settings/ValidationSettingsTool.cs +++ b/Editor/EditorAddons/Settings/ValidationSettingsTool.cs @@ -1,13 +1,15 @@ using Better.EditorTools.SettingsTools; +using UnityEditor; namespace Better.Validation.EditorAddons.Settings { - public class ValidationSettingsTool : ProjectSettingsTools + public class ValidationSettingsTool : ProjectSettingsTools { - public const string SettingMenuItem = nameof(Validation); + private const string SettingMenuItem = nameof(Validation); public const string MenuItemPrefix = ProjectSettingsRegisterer.BetterPrefix + "/" + SettingMenuItem; - public ValidationSettingsTool() : base(SettingMenuItem, SettingMenuItem) + public ValidationSettingsTool() : base(SettingMenuItem, SettingMenuItem, new string[] + { ProjectSettingsRegisterer.BetterPrefix, SettingMenuItem, nameof(Editor), ProjectSettingsRegisterer.ResourcesPrefix }) { } } diff --git a/Editor/EditorAddons/Utilities/AnyTypeComparer.cs b/Editor/EditorAddons/Utilities/AnyTypeComparer.cs deleted file mode 100644 index d06c568..0000000 --- a/Editor/EditorAddons/Utilities/AnyTypeComparer.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using Better.EditorTools.Comparers; - -namespace Better.Validation.EditorAddons.Utilities -{ - public class AnyTypeComparer : BaseComparer, IEqualityComparer - { - public bool Equals(Type x, Type y) - { - return true; - } - - public int GetHashCode(Type obj) - { - return 0; - } - } -} \ No newline at end of file diff --git a/Editor/EditorAddons/Utilities/AnyTypeComparer.cs.meta b/Editor/EditorAddons/Utilities/AnyTypeComparer.cs.meta deleted file mode 100644 index 502644c..0000000 --- a/Editor/EditorAddons/Utilities/AnyTypeComparer.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 1643c2a2d1304c9389f799c1ab67c394 -timeCreated: 1685276055 \ No newline at end of file diff --git a/Editor/EditorAddons/Utilities/BetterGUIUtility.cs b/Editor/EditorAddons/Utilities/BetterGUIUtility.cs deleted file mode 100644 index 79cea9b..0000000 --- a/Editor/EditorAddons/Utilities/BetterGUIUtility.cs +++ /dev/null @@ -1,14 +0,0 @@ -using UnityEngine; - -namespace Better.Validation.EditorAddons.Utilities -{ - public static class BetterGUIUtility - { - public static int Toolbar(int groupID, string[] groupNames, out bool changed) - { - var id = GUILayout.Toolbar(groupID, groupNames); - changed = id != groupID; - return id; - } - } -} \ No newline at end of file diff --git a/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs b/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs new file mode 100644 index 0000000..76247af --- /dev/null +++ b/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs @@ -0,0 +1,103 @@ +using Better.EditorTools.Helpers; +using UnityEditor; +using UnityEngine; + +namespace Better.Validation.EditorAddons.Utilities +{ + public static class ToolsGUIUtility + { + public static readonly GUIStyle SelectionStyle = new GUIStyle("TV Selection") + { + fixedWidth = -0, + stretchWidth = true, + padding = new RectOffset(Styles.InspectorDefaultMargins.padding.left, 0, + 1, 0), + margin = new RectOffset() + }; + + public static readonly GUIStyle Label = new GUIStyle(EditorStyles.label) + { + fixedWidth = -0, + stretchWidth = true, + padding = new RectOffset(Styles.InspectorDefaultMargins.padding.left, 0, + 1, 0), + margin = new RectOffset(), + fixedHeight = EditorGUIUtility.singleLineHeight + }; + + public static readonly GUIStyle TopPaddingContent = new GUIStyle(EditorStyles.label) + { + fixedWidth = -0, + stretchWidth = true, + padding = new RectOffset(0, 0, Styles.DefaultContentMargins.padding.top + 2, 0), + 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); + changed = id != groupID; + 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)); + r.width = thickness; + r.x -= 4; + r.y -= 2; + r.height = Screen.height; + EditorGUI.DrawRect(r, color); + } + + public static int Sidebar(ref Vector2 scrollView, int groupID, string[] groupNames, out bool changed) + { + using (var scroll = new EditorGUILayout.ScrollViewScope(scrollView, GUILayout.Width(250f))) + { + using (new EditorGUILayout.VerticalScope(TopPaddingContent)) + { + for (var id = 0; id < groupNames.Length; id++) + { + var buffer = id == groupID ? SelectionStyle : Label; + if (GUILayout.Button(groupNames[id], buffer)) + { + changed = id != groupID; + return id; + } + } + + GUILayout.FlexibleSpace(); + } + + scrollView = scroll.scrollPosition; + } + + DrawVerticalLineFull(Color.black, 1, 0); + changed = false; + return groupID; + } + } +} \ No newline at end of file diff --git a/Editor/EditorAddons/Utilities/BetterGUIUtility.cs.meta b/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs.meta similarity index 100% rename from Editor/EditorAddons/Utilities/BetterGUIUtility.cs.meta rename to Editor/EditorAddons/Utilities/ToolsGUIUtility.cs.meta diff --git a/Editor/EditorAddons/Utilities/ValidationUtility.cs b/Editor/EditorAddons/Utilities/ValidationUtility.cs index f03010d..3f5d6c6 100644 --- a/Editor/EditorAddons/Utilities/ValidationUtility.cs +++ b/Editor/EditorAddons/Utilities/ValidationUtility.cs @@ -3,7 +3,7 @@ using Better.EditorTools.Comparers; using Better.EditorTools.Drawers.Base; using Better.EditorTools.Utilities; -using Better.Validation.EditorAddons.ValidationWrappers; +using Better.Validation.EditorAddons.Wrappers; using Better.Validation.Runtime.Attributes; namespace Better.Validation.EditorAddons.Utilities diff --git a/Editor/EditorAddons/ValidationCommandData.cs b/Editor/EditorAddons/ValidationCommandData.cs index de02c16..14a8aed 100644 --- a/Editor/EditorAddons/ValidationCommandData.cs +++ b/Editor/EditorAddons/ValidationCommandData.cs @@ -1,7 +1,8 @@ using System; using Better.Validation.EditorAddons.ContextResolver; +using Better.Validation.EditorAddons.Iteration; using Better.Validation.EditorAddons.Utilities; -using Better.Validation.EditorAddons.ValidationWrappers; +using Better.Validation.EditorAddons.Wrappers; using Better.Validation.Runtime.Attributes; using UnityEditor; using Object = UnityEngine.Object; diff --git a/Editor/EditorAddons/ValidatorCommands.cs b/Editor/EditorAddons/ValidatorCommands.cs index b6eb570..7b02d46 100644 --- a/Editor/EditorAddons/ValidatorCommands.cs +++ b/Editor/EditorAddons/ValidatorCommands.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Threading.Tasks; using Better.Validation.EditorAddons.ContextResolver; +using Better.Validation.EditorAddons.Iteration; using Better.Validation.EditorAddons.Utilities; using UnityEditor; using UnityEditor.SceneManagement; @@ -45,7 +46,7 @@ public List ValidateAttributesInAllScenes() return list; } - public List MissingInAllScenes() + public List FindMissingInAllScenes() { Iterator.SetContext(SceneResolver.Instance); var list = new List(); diff --git a/Editor/EditorAddons/WindowModule/Pages/ButtonPage.cs b/Editor/EditorAddons/WindowModule/Pages/ButtonPage.cs index c616752..415ebcb 100644 --- a/Editor/EditorAddons/WindowModule/Pages/ButtonPage.cs +++ b/Editor/EditorAddons/WindowModule/Pages/ButtonPage.cs @@ -1,5 +1,10 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Linq; +using Better.EditorTools.Helpers; +using Better.Extensions.Runtime; using Better.Validation.EditorAddons.Utilities; +using Better.Validation.EditorAddons.WindowModule.Pages.Tab; using UnityEditor; using UnityEngine; @@ -10,30 +15,37 @@ public class ButtonPage : IWindowPage private ValidatorCommands _commands; private int _groupID; - private string[] _groupNames = new[] - { - "Validate", "Find Missing References" - }; + private string[] _groupNames; + + private IValidationTab[] _buttons; + private IValidationTab _currentTab; + private Vector2 _scrollPosition; public void Initialize() { _commands = new ValidatorCommands(); + _buttons = typeof(IValidationTab).GetAllInheritedType().Select(type => (IValidationTab)Activator.CreateInstance(type)).OrderBy(tab => tab.Order) + .ToArray(); + foreach (var validationButton in _buttons) + { + validationButton.Initialize(); + } + + _currentTab = _buttons.FirstOrDefault(); + _groupNames = _buttons.Select(button => button.GetTabName()).ToArray(); } public IWindowPage DrawUpdate() { List list = null; - using (new EditorGUILayout.VerticalScope()) + using (new EditorGUILayout.HorizontalScope()) { - _groupID = BetterGUIUtility.Toolbar(_groupID, _groupNames, out var isChanged); - using (new EditorGUILayout.HorizontalScope()) + _groupID = ToolsGUIUtility.Sidebar(ref _scrollPosition, _groupID, _groupNames, out var isChanged); + if (isChanged) + _currentTab = _buttons[_groupID]; + using (new EditorGUILayout.HorizontalScope(Styles.DefaultContentMargins)) { - list = _groupID switch - { - 0 => DrawValidationCommandData(), - 1 => DrawFindMissingReferences(), - _ => null - }; + list = _currentTab.DrawUpdate(); } } @@ -48,46 +60,6 @@ public IWindowPage DrawUpdate() return null; } - private List DrawFindMissingReferences() - { - if (GUILayout.Button("In Current Scene")) - { - return _commands.FindMissingReferencesInCurrentScene(); - } - - if (GUILayout.Button("In All Scenes")) - { - return _commands.MissingInAllScenes(); - } - - if (GUILayout.Button("In Project")) - { - return _commands.FindMissingReferencesInProject(); - } - - return null; - } - - private List DrawValidationCommandData() - { - if (GUILayout.Button("In Current Scene")) - { - return _commands.ValidateAttributesInCurrentScene(); - } - - if (GUILayout.Button("In All Scenes")) - { - return _commands.ValidateAttributesInAllScenes(); - } - - if (GUILayout.Button("In Project")) - { - return _commands.ValidateAttributesInProject(); - } - - return null; - } - public void Deconstruct() { } diff --git a/Editor/EditorAddons/WindowModule/Pages/ResultPage.cs b/Editor/EditorAddons/WindowModule/Pages/ResultPage.cs index aa25f5e..377997a 100644 --- a/Editor/EditorAddons/WindowModule/Pages/ResultPage.cs +++ b/Editor/EditorAddons/WindowModule/Pages/ResultPage.cs @@ -55,7 +55,7 @@ public IWindowPage DrawUpdate() } else { - _groupID = BetterGUIUtility.Toolbar(_groupID, _groupNames, out var isChanged); + _groupID = ToolsGUIUtility.Toolbar(_groupID, _groupNames, out var isChanged); if (isChanged) { _collectionDrawer = _groups[_groupID].CopyFrom(_collectionDrawer); diff --git a/Editor/EditorAddons/WindowModule/Pages/Tab.meta b/Editor/EditorAddons/WindowModule/Pages/Tab.meta new file mode 100644 index 0000000..fe22c86 --- /dev/null +++ b/Editor/EditorAddons/WindowModule/Pages/Tab.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e5edd0611c5547e6b57f33764419e7e0 +timeCreated: 1689118840 \ No newline at end of file diff --git a/Editor/EditorAddons/WindowModule/Pages/Tab/BaseValidationTab.cs b/Editor/EditorAddons/WindowModule/Pages/Tab/BaseValidationTab.cs new file mode 100644 index 0000000..55ff100 --- /dev/null +++ b/Editor/EditorAddons/WindowModule/Pages/Tab/BaseValidationTab.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace Better.Validation.EditorAddons.WindowModule.Pages.Tab +{ + public abstract class BaseValidationTab : IValidationTab + { + protected ValidatorCommands _commands; + public abstract int Order { get; } + public abstract string GetTabName(); + + public virtual void Initialize() + { + _commands = new ValidatorCommands(); + } + + public abstract List DrawUpdate(); + } +} \ No newline at end of file diff --git a/Editor/EditorAddons/WindowModule/Pages/Tab/BaseValidationTab.cs.meta b/Editor/EditorAddons/WindowModule/Pages/Tab/BaseValidationTab.cs.meta new file mode 100644 index 0000000..1561235 --- /dev/null +++ b/Editor/EditorAddons/WindowModule/Pages/Tab/BaseValidationTab.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 853e004bab314be1952685b7735af9b6 +timeCreated: 1689118828 \ No newline at end of file diff --git a/Editor/EditorAddons/WindowModule/Pages/Tab/IValidationTab.cs b/Editor/EditorAddons/WindowModule/Pages/Tab/IValidationTab.cs new file mode 100644 index 0000000..aa7176f --- /dev/null +++ b/Editor/EditorAddons/WindowModule/Pages/Tab/IValidationTab.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace Better.Validation.EditorAddons.WindowModule.Pages.Tab +{ + public interface IValidationTab + { + public int Order { get; } + public string GetTabName(); + public void Initialize(); + public List DrawUpdate(); + } +} \ No newline at end of file diff --git a/Editor/EditorAddons/WindowModule/Pages/Tab/IValidationTab.cs.meta b/Editor/EditorAddons/WindowModule/Pages/Tab/IValidationTab.cs.meta new file mode 100644 index 0000000..f62a982 --- /dev/null +++ b/Editor/EditorAddons/WindowModule/Pages/Tab/IValidationTab.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b273c929ef914b539178217812548f10 +timeCreated: 1689118828 \ No newline at end of file diff --git a/Editor/EditorAddons/WindowModule/Pages/Tab/MissingReferenceTab.cs b/Editor/EditorAddons/WindowModule/Pages/Tab/MissingReferenceTab.cs new file mode 100644 index 0000000..7c8be97 --- /dev/null +++ b/Editor/EditorAddons/WindowModule/Pages/Tab/MissingReferenceTab.cs @@ -0,0 +1,62 @@ +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +namespace Better.Validation.EditorAddons.WindowModule.Pages.Tab +{ + public class MissingReferenceTab : BaseValidationTab + { + private GUIContent _bottomText; + private GUIStyle _style; + private const string Name = "Find Missing References"; + + public override int Order => 1; + + public override string GetTabName() + { + return Name; + } + + public override void Initialize() + { + base.Initialize(); + _bottomText = new GUIContent("Those commands looking for missing references in Unity SerializedProperties"); + _style = new GUIStyle(EditorStyles.label); + _style.wordWrap = true; + } + + public override List DrawUpdate() + { + return DrawButtons(); + } + + private List DrawButtons() + { + using (new EditorGUILayout.VerticalScope()) + { + using (new EditorGUILayout.HorizontalScope()) + { + if (GUILayout.Button("In Current Scene")) + { + return _commands.FindMissingReferencesInCurrentScene(); + } + + if (GUILayout.Button("In All Scenes")) + { + return _commands.FindMissingInAllScenes(); + } + + if (GUILayout.Button("In Project")) + { + return _commands.FindMissingReferencesInProject(); + } + } + + GUILayout.FlexibleSpace(); + EditorGUILayout.LabelField(_bottomText, _style); + } + + return null; + } + } +} \ No newline at end of file diff --git a/Editor/EditorAddons/WindowModule/Pages/Tab/MissingReferenceTab.cs.meta b/Editor/EditorAddons/WindowModule/Pages/Tab/MissingReferenceTab.cs.meta new file mode 100644 index 0000000..c752454 --- /dev/null +++ b/Editor/EditorAddons/WindowModule/Pages/Tab/MissingReferenceTab.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1dd0fef839e84e39b0091f9bbb839612 +timeCreated: 1689118828 \ No newline at end of file diff --git a/Editor/EditorAddons/WindowModule/Pages/Tab/ValidateTab.cs b/Editor/EditorAddons/WindowModule/Pages/Tab/ValidateTab.cs new file mode 100644 index 0000000..bdae266 --- /dev/null +++ b/Editor/EditorAddons/WindowModule/Pages/Tab/ValidateTab.cs @@ -0,0 +1,62 @@ +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +namespace Better.Validation.EditorAddons.WindowModule.Pages.Tab +{ + public class ValidateTab : BaseValidationTab + { + private GUIContent _bottomText; + private GUIStyle _style; + private const string Name = "Validate"; + + public override int Order => 0; + + public override string GetTabName() + { + return Name; + } + + public override void Initialize() + { + base.Initialize(); + _bottomText = new GUIContent("Validation commands will go through Unity SerializedProperties and run validation attributes"); + _style = new GUIStyle(EditorStyles.label); + _style.wordWrap = true; + } + + public override List DrawUpdate() + { + return DrawButtons(); + } + + private List DrawButtons() + { + using (new EditorGUILayout.VerticalScope()) + { + using (new EditorGUILayout.HorizontalScope()) + { + if (GUILayout.Button("In Current Scene")) + { + return _commands.ValidateAttributesInCurrentScene(); + } + + if (GUILayout.Button("In All Scenes")) + { + return _commands.ValidateAttributesInAllScenes(); + } + + if (GUILayout.Button("In Project")) + { + return _commands.ValidateAttributesInProject(); + } + } + + GUILayout.FlexibleSpace(); + EditorGUILayout.LabelField(_bottomText, _style); + } + + return null; + } + } +} \ No newline at end of file diff --git a/Editor/EditorAddons/WindowModule/Pages/Tab/ValidateTab.cs.meta b/Editor/EditorAddons/WindowModule/Pages/Tab/ValidateTab.cs.meta new file mode 100644 index 0000000..d7d1f8e --- /dev/null +++ b/Editor/EditorAddons/WindowModule/Pages/Tab/ValidateTab.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f01c493a14454027afe22e26ae2b9406 +timeCreated: 1689118819 \ No newline at end of file diff --git a/Editor/EditorAddons/ValidationWrappers.meta b/Editor/EditorAddons/Wrappers.meta similarity index 100% rename from Editor/EditorAddons/ValidationWrappers.meta rename to Editor/EditorAddons/Wrappers.meta diff --git a/Editor/EditorAddons/ValidationWrappers/DataValidationWrapper.cs b/Editor/EditorAddons/Wrappers/DataValidationWrapper.cs similarity index 98% rename from Editor/EditorAddons/ValidationWrappers/DataValidationWrapper.cs rename to Editor/EditorAddons/Wrappers/DataValidationWrapper.cs index 31f8dc7..c71fed7 100644 --- a/Editor/EditorAddons/ValidationWrappers/DataValidationWrapper.cs +++ b/Editor/EditorAddons/Wrappers/DataValidationWrapper.cs @@ -6,7 +6,7 @@ using Better.Tools.Runtime; using Better.Validation.Runtime.Attributes; -namespace Better.Validation.EditorAddons.ValidationWrappers +namespace Better.Validation.EditorAddons.Wrappers { public class DataValidationWrapper : PropertyValidationWrapper { diff --git a/Editor/EditorAddons/ValidationWrappers/DataValidationWrapper.cs.meta b/Editor/EditorAddons/Wrappers/DataValidationWrapper.cs.meta similarity index 100% rename from Editor/EditorAddons/ValidationWrappers/DataValidationWrapper.cs.meta rename to Editor/EditorAddons/Wrappers/DataValidationWrapper.cs.meta diff --git a/Editor/EditorAddons/ValidationWrappers/MissingComponentWrapper.cs b/Editor/EditorAddons/Wrappers/MissingComponentWrapper.cs similarity index 94% rename from Editor/EditorAddons/ValidationWrappers/MissingComponentWrapper.cs rename to Editor/EditorAddons/Wrappers/MissingComponentWrapper.cs index db24af1..31a5f6f 100644 --- a/Editor/EditorAddons/ValidationWrappers/MissingComponentWrapper.cs +++ b/Editor/EditorAddons/Wrappers/MissingComponentWrapper.cs @@ -2,7 +2,7 @@ using Better.Validation.Runtime.Attributes; using UnityEngine; -namespace Better.Validation.EditorAddons.ValidationWrappers +namespace Better.Validation.EditorAddons.Wrappers { public class MissingComponentWrapper : ValidationWrapper { diff --git a/Editor/EditorAddons/ValidationWrappers/MissingComponentWrapper.cs.meta b/Editor/EditorAddons/Wrappers/MissingComponentWrapper.cs.meta similarity index 100% rename from Editor/EditorAddons/ValidationWrappers/MissingComponentWrapper.cs.meta rename to Editor/EditorAddons/Wrappers/MissingComponentWrapper.cs.meta diff --git a/Editor/EditorAddons/ValidationWrappers/NotNullWrapper.cs b/Editor/EditorAddons/Wrappers/NotNullWrapper.cs similarity index 96% rename from Editor/EditorAddons/ValidationWrappers/NotNullWrapper.cs rename to Editor/EditorAddons/Wrappers/NotNullWrapper.cs index b433c01..8ab4894 100644 --- a/Editor/EditorAddons/ValidationWrappers/NotNullWrapper.cs +++ b/Editor/EditorAddons/Wrappers/NotNullWrapper.cs @@ -3,7 +3,7 @@ using Better.Extensions.Runtime; using UnityEditor; -namespace Better.Validation.EditorAddons.ValidationWrappers +namespace Better.Validation.EditorAddons.Wrappers { public class NotNullWrapper : PropertyValidationWrapper { diff --git a/Editor/EditorAddons/ValidationWrappers/NotNullWrapper.cs.meta b/Editor/EditorAddons/Wrappers/NotNullWrapper.cs.meta similarity index 100% rename from Editor/EditorAddons/ValidationWrappers/NotNullWrapper.cs.meta rename to Editor/EditorAddons/Wrappers/NotNullWrapper.cs.meta diff --git a/Editor/EditorAddons/ValidationWrappers/PrefabWrapper.cs b/Editor/EditorAddons/Wrappers/PrefabWrapper.cs similarity index 93% rename from Editor/EditorAddons/ValidationWrappers/PrefabWrapper.cs rename to Editor/EditorAddons/Wrappers/PrefabWrapper.cs index 39ea570..876916d 100644 --- a/Editor/EditorAddons/ValidationWrappers/PrefabWrapper.cs +++ b/Editor/EditorAddons/Wrappers/PrefabWrapper.cs @@ -2,7 +2,7 @@ using Better.EditorTools.Helpers.Caching; using UnityEditor; -namespace Better.Validation.EditorAddons.ValidationWrappers +namespace Better.Validation.EditorAddons.Wrappers { public class PrefabWrapper : NotNullWrapper { diff --git a/Editor/EditorAddons/ValidationWrappers/PrefabWrapper.cs.meta b/Editor/EditorAddons/Wrappers/PrefabWrapper.cs.meta similarity index 100% rename from Editor/EditorAddons/ValidationWrappers/PrefabWrapper.cs.meta rename to Editor/EditorAddons/Wrappers/PrefabWrapper.cs.meta diff --git a/Editor/EditorAddons/ValidationWrappers/PropertyValidationWrapper.cs b/Editor/EditorAddons/Wrappers/PropertyValidationWrapper.cs similarity index 91% rename from Editor/EditorAddons/ValidationWrappers/PropertyValidationWrapper.cs rename to Editor/EditorAddons/Wrappers/PropertyValidationWrapper.cs index b87ff45..038f476 100644 --- a/Editor/EditorAddons/ValidationWrappers/PropertyValidationWrapper.cs +++ b/Editor/EditorAddons/Wrappers/PropertyValidationWrapper.cs @@ -1,7 +1,7 @@ using Better.Validation.Runtime.Attributes; using UnityEditor; -namespace Better.Validation.EditorAddons.ValidationWrappers +namespace Better.Validation.EditorAddons.Wrappers { public abstract class PropertyValidationWrapper : ValidationWrapper { diff --git a/Editor/EditorAddons/ValidationWrappers/PropertyValidationWrapper.cs.meta b/Editor/EditorAddons/Wrappers/PropertyValidationWrapper.cs.meta similarity index 100% rename from Editor/EditorAddons/ValidationWrappers/PropertyValidationWrapper.cs.meta rename to Editor/EditorAddons/Wrappers/PropertyValidationWrapper.cs.meta diff --git a/Editor/EditorAddons/ValidationWrappers/RequireComponentWrapper.cs b/Editor/EditorAddons/Wrappers/RequireComponentWrapper.cs similarity index 97% rename from Editor/EditorAddons/ValidationWrappers/RequireComponentWrapper.cs rename to Editor/EditorAddons/Wrappers/RequireComponentWrapper.cs index 8005a2a..15329d6 100644 --- a/Editor/EditorAddons/ValidationWrappers/RequireComponentWrapper.cs +++ b/Editor/EditorAddons/Wrappers/RequireComponentWrapper.cs @@ -5,7 +5,7 @@ using UnityEditor; using UnityEngine; -namespace Better.Validation.EditorAddons.ValidationWrappers +namespace Better.Validation.EditorAddons.Wrappers { public class RequireComponentWrapper : PropertyValidationWrapper { diff --git a/Editor/EditorAddons/ValidationWrappers/RequireComponentWrapper.cs.meta b/Editor/EditorAddons/Wrappers/RequireComponentWrapper.cs.meta similarity index 100% rename from Editor/EditorAddons/ValidationWrappers/RequireComponentWrapper.cs.meta rename to Editor/EditorAddons/Wrappers/RequireComponentWrapper.cs.meta diff --git a/Editor/EditorAddons/ValidationWrappers/SceneReferenceWrapper.cs b/Editor/EditorAddons/Wrappers/SceneReferenceWrapper.cs similarity index 97% rename from Editor/EditorAddons/ValidationWrappers/SceneReferenceWrapper.cs rename to Editor/EditorAddons/Wrappers/SceneReferenceWrapper.cs index 5e0f204..c9bbf57 100644 --- a/Editor/EditorAddons/ValidationWrappers/SceneReferenceWrapper.cs +++ b/Editor/EditorAddons/Wrappers/SceneReferenceWrapper.cs @@ -4,7 +4,7 @@ using UnityEditor; using UnityEngine; -namespace Better.Validation.EditorAddons.ValidationWrappers +namespace Better.Validation.EditorAddons.Wrappers { public class SceneReferenceWrapper : NotNullWrapper { diff --git a/Editor/EditorAddons/ValidationWrappers/SceneReferenceWrapper.cs.meta b/Editor/EditorAddons/Wrappers/SceneReferenceWrapper.cs.meta similarity index 100% rename from Editor/EditorAddons/ValidationWrappers/SceneReferenceWrapper.cs.meta rename to Editor/EditorAddons/Wrappers/SceneReferenceWrapper.cs.meta diff --git a/Editor/EditorAddons/ValidationWrappers/ValidationWrapper.cs b/Editor/EditorAddons/Wrappers/ValidationWrapper.cs similarity index 92% rename from Editor/EditorAddons/ValidationWrappers/ValidationWrapper.cs rename to Editor/EditorAddons/Wrappers/ValidationWrapper.cs index 11e754f..aa8f0ab 100644 --- a/Editor/EditorAddons/ValidationWrappers/ValidationWrapper.cs +++ b/Editor/EditorAddons/Wrappers/ValidationWrapper.cs @@ -2,7 +2,7 @@ using Better.EditorTools.Utilities; using Better.Validation.Runtime.Attributes; -namespace Better.Validation.EditorAddons.ValidationWrappers +namespace Better.Validation.EditorAddons.Wrappers { public abstract class ValidationWrapper : UtilityWrapper { diff --git a/Editor/EditorAddons/ValidationWrappers/ValidationWrapper.cs.meta b/Editor/EditorAddons/Wrappers/ValidationWrapper.cs.meta similarity index 100% rename from Editor/EditorAddons/ValidationWrappers/ValidationWrapper.cs.meta rename to Editor/EditorAddons/Wrappers/ValidationWrapper.cs.meta diff --git a/Editor/EditorAddons/ValidationWrappers/ValidationWrapperExtensions.cs b/Editor/EditorAddons/Wrappers/ValidationWrapperExtensions.cs similarity index 85% rename from Editor/EditorAddons/ValidationWrappers/ValidationWrapperExtensions.cs rename to Editor/EditorAddons/Wrappers/ValidationWrapperExtensions.cs index f80c08d..f777fd2 100644 --- a/Editor/EditorAddons/ValidationWrappers/ValidationWrapperExtensions.cs +++ b/Editor/EditorAddons/Wrappers/ValidationWrapperExtensions.cs @@ -1,6 +1,6 @@ using System; -namespace Better.Validation.EditorAddons.ValidationWrappers +namespace Better.Validation.EditorAddons.Wrappers { public static class ValidationWrapperExtensions { diff --git a/Editor/EditorAddons/ValidationWrappers/ValidationWrapperExtensions.cs.meta b/Editor/EditorAddons/Wrappers/ValidationWrapperExtensions.cs.meta similarity index 100% rename from Editor/EditorAddons/ValidationWrappers/ValidationWrapperExtensions.cs.meta rename to Editor/EditorAddons/Wrappers/ValidationWrapperExtensions.cs.meta diff --git a/Samples.meta b/Samples.meta new file mode 100644 index 0000000..e8780db --- /dev/null +++ b/Samples.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 26391ed6464ef0b4a8c6e7ca02e6c628 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples~/TestSamples.meta b/Samples/TestSamples.meta similarity index 100% rename from Samples~/TestSamples.meta rename to Samples/TestSamples.meta diff --git a/Samples/TestSamples/Editor.meta b/Samples/TestSamples/Editor.meta new file mode 100644 index 0000000..7ff51b9 --- /dev/null +++ b/Samples/TestSamples/Editor.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: bfdfd9280e734590bb496b3086c28fdb +timeCreated: 1689120082 \ No newline at end of file diff --git a/Samples/TestSamples/Editor/TestValidationPage.cs b/Samples/TestSamples/Editor/TestValidationPage.cs new file mode 100644 index 0000000..688a6b0 --- /dev/null +++ b/Samples/TestSamples/Editor/TestValidationPage.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using Better.Validation.EditorAddons; +using Better.Validation.EditorAddons.WindowModule.Pages.Tab; +using UnityEditor; +using UnityEngine; + +namespace BetterValidation.Samples.TestSamples.Editor +{ + public class TestValidationPage : IValidationTab + { + public int Order => 3; + + public string GetTabName() + { + return "Custom Validation"; + } + + public void Initialize() + { + } + + public List DrawUpdate() + { + using (new EditorGUILayout.VerticalScope()) + { + using (new EditorGUILayout.HorizontalScope()) + { + if (GUILayout.Button("This button doing nothing")) + { + // return list of ValidationCommandData + } + } + } + + return null; + } + } +} \ No newline at end of file diff --git a/Samples/TestSamples/Editor/TestValidationPage.cs.meta b/Samples/TestSamples/Editor/TestValidationPage.cs.meta new file mode 100644 index 0000000..3b9a787 --- /dev/null +++ b/Samples/TestSamples/Editor/TestValidationPage.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 25a9a71e7b834b3c97130e4a21afb48a +timeCreated: 1689120131 \ No newline at end of file diff --git a/Samples/TestSamples/Editor/TestValidationStep.cs b/Samples/TestSamples/Editor/TestValidationStep.cs new file mode 100644 index 0000000..0c72280 --- /dev/null +++ b/Samples/TestSamples/Editor/TestValidationStep.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using Better.Validation.EditorAddons; +using Better.Validation.EditorAddons.PreBuildValidation.Interfaces; +using UnityEngine; + +namespace BetterValidation.Samples.TestSamples.Editor +{ + [Serializable] + public class TestValidationStep : IBuildValidationStep + { + [SerializeField] private string customText = "You can add your custom validation step"; + + public List GatherValidationData() + { + return new List(); + } + } +} diff --git a/Samples/TestSamples/Editor/TestValidationStep.cs.meta b/Samples/TestSamples/Editor/TestValidationStep.cs.meta new file mode 100644 index 0000000..9dfba52 --- /dev/null +++ b/Samples/TestSamples/Editor/TestValidationStep.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e9896efaf79e3064389251bfd5530997 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples~/TestSamples/GameObject 1.prefab b/Samples/TestSamples/GameObject 1.prefab similarity index 100% rename from Samples~/TestSamples/GameObject 1.prefab rename to Samples/TestSamples/GameObject 1.prefab diff --git a/Samples~/TestSamples/GameObject 1.prefab.meta b/Samples/TestSamples/GameObject 1.prefab.meta similarity index 100% rename from Samples~/TestSamples/GameObject 1.prefab.meta rename to Samples/TestSamples/GameObject 1.prefab.meta diff --git a/Samples~/TestSamples/Test.cs b/Samples/TestSamples/Test.cs similarity index 100% rename from Samples~/TestSamples/Test.cs rename to Samples/TestSamples/Test.cs diff --git a/Samples~/TestSamples/Test.cs.meta b/Samples/TestSamples/Test.cs.meta similarity index 100% rename from Samples~/TestSamples/Test.cs.meta rename to Samples/TestSamples/Test.cs.meta diff --git a/Samples~/TestSamples/TestRequire.cs b/Samples/TestSamples/TestRequire.cs similarity index 100% rename from Samples~/TestSamples/TestRequire.cs rename to Samples/TestSamples/TestRequire.cs diff --git a/Samples~/TestSamples/TestRequire.cs.meta b/Samples/TestSamples/TestRequire.cs.meta similarity index 100% rename from Samples~/TestSamples/TestRequire.cs.meta rename to Samples/TestSamples/TestRequire.cs.meta diff --git a/Samples~/TestSamples/test.unity b/Samples/TestSamples/test.unity similarity index 100% rename from Samples~/TestSamples/test.unity rename to Samples/TestSamples/test.unity diff --git a/Samples~/TestSamples/test.unity.meta b/Samples/TestSamples/test.unity.meta similarity index 100% rename from Samples~/TestSamples/test.unity.meta rename to Samples/TestSamples/test.unity.meta diff --git a/package.json b/package.json index 572eb9e..955448d 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "com.uurha.bettervalidation", "displayName": "Better Validation", - "version": "1.0.5", + "version": "1.0.51", "unity": "2020.1", "description": " ", "dependencies": { - "com.uurha.bettereditortools": "1.0.5" + "com.uurha.bettereditortools": "1.0.53" }, "author": { "name": "Arcueid D'athemon",