From f48b5c4fe4a745378c1612371d34de93596e29dd Mon Sep 17 00:00:00 2001 From: uurhaa Date: Fri, 8 Mar 2024 09:40:38 +0100 Subject: [PATCH] Clean up --- Assets/Better/Validation/Resources.meta | 8 ++ .../Resources/ValidationSettings.asset | 26 ++++ .../Resources/ValidationSettings.asset.meta | 8 ++ .../Editor/BetterValidation.Editor.asmdef | 15 ++- .../ContextResolver/AssetResolver.cs | 7 +- .../ContextResolver/IContextResolver.cs | 2 +- .../ContextResolver/SceneResolver.cs | 7 +- .../EditorAddons/Drawers/ValidationDrawer.cs | 16 +-- .../EditorAddons/Iteration/IterationData.cs | 6 +- .../Editor/EditorAddons/Iteration/Iterator.cs | 28 ++-- .../EditorAddons/Iteration/IteratorFilter.cs | 35 +++-- .../Editor/EditorAddons/MenuItems.cs | 2 +- .../Interfaces/IBuildValidationStep.cs | 4 +- .../Models/AllSceneValidationStep.cs | 14 ++ .../Models/AllSceneValidationStep.cs.meta | 3 + .../Models/ProjectValidationStep.cs | 16 +-- .../ValidationBuildProcess.cs | 36 +++--- .../Settings/BuildValidationStepsDrawer.cs | 12 +- .../Settings/ValidationSettingProvider.cs | 22 ++-- .../Settings/ValidationSettings.cs | 24 ++-- .../Settings/ValidationSettingsEditor.cs | 11 +- .../Settings/ValidationSettingsTool.cs | 17 --- .../Settings/ValidationSettingsTool.cs.meta | 3 - .../Utilities/GameObjectExtensions.cs | 88 ------------- .../{Utilities.meta => Utility.meta} | 0 .../FoldoutHeaderGroupScope.cs | 2 +- .../FoldoutHeaderGroupScope.cs.meta | 0 .../Utility/GameObjectExtensions.cs | 122 ++++++++++++++++++ .../GameObjectExtensions.cs.meta | 0 .../{Utilities => Utility}/ToolsGUIUtility.cs | 8 +- .../ToolsGUIUtility.cs.meta | 0 .../ValidationAttributeUtility.cs} | 10 +- .../ValidationAttributeUtility.cs.meta} | 0 .../Utility/ValidationExtensions.cs | 21 +++ .../ValidationExtensions.cs.meta | 0 .../ValidationUtility.cs} | 65 ++++------ .../Utility/ValidationUtility.cs.meta | 3 + .../EditorAddons/ValidationCommandData.cs | 5 +- .../Editor/EditorAddons/ValidatorCommands.cs | 31 +++-- .../CollectionDrawing/CollectionDrawer.cs | 13 +- .../CollectionDrawing/DefaultDrawer.cs | 2 +- .../GroupDictionaryDrawer.cs | 40 +++++- .../CollectionDrawing/ObjectGroupDrawer.cs | 11 +- .../CollectionDrawing/TypeGroupDrawer.cs | 16 +-- .../GameObjectGroupingComparer.cs | 2 +- .../WindowModule/Pages/ButtonPage.cs | 18 +-- .../WindowModule/Pages/IWindowPage.cs | 4 +- .../WindowModule/Pages/ResultPage.cs | 25 ++-- .../Pages/Tab/BaseValidationTab.cs | 2 +- .../WindowModule/Pages/Tab/IValidationTab.cs | 2 +- .../Pages/Tab/MissingReferenceTab.cs | 2 +- .../WindowModule/Pages/Tab/ValidateTab.cs | 2 +- .../WindowModule/ValidationWindow.cs | 1 - .../Wrappers/DataValidationWrapper.cs | 16 +-- .../Wrappers/MissingComponentWrapper.cs | 4 +- .../Wrappers/MissingReferenceWrapper.cs | 29 +++++ .../Wrappers/MissingReferenceWrapper.cs.meta | 3 + .../EditorAddons/Wrappers/NotNullWrapper.cs | 28 +--- .../EditorAddons/Wrappers/PrefabWrapper.cs | 6 +- .../Wrappers/RequireComponentWrapper.cs | 8 +- .../Wrappers/SceneReferenceWrapper.cs | 10 +- .../Wrappers/ValidationWrapper.cs | 12 +- .../Attributes/DataValidationAttribute.cs | 4 +- .../Runtime/Attributes/FindAttribute.cs | 4 +- .../Runtime/Attributes/NotNullAttribute.cs | 4 +- .../Attributes/PrefabReferenceAttribute.cs | 4 +- .../Attributes/SceneReferenceAttribute.cs | 4 +- .../Runtime/Attributes/ValidationAttribute.cs | 7 +- .../Runtime/BetterValidation.Runtime.asmdef | 5 +- .../TestSamples/Editor/TestValidationPage.cs | 2 +- .../TestSamples/Editor/TestValidationStep.cs | 4 +- Assets/BetterValidation/package.json | 9 +- BetterValidation.Editor.csproj.DotSettings | 8 ++ BetterValidation.Runtime.csproj.DotSettings | 3 + Packages/manifest.json | 15 ++- Packages/packages-lock.json | 83 +++++++----- ProjectSettings/PackageManagerSettings.asset | 5 +- ProjectSettings/ProjectVersion.txt | 4 +- 78 files changed, 624 insertions(+), 474 deletions(-) create mode 100644 Assets/Better/Validation/Resources.meta create mode 100644 Assets/Better/Validation/Resources/ValidationSettings.asset create mode 100644 Assets/Better/Validation/Resources/ValidationSettings.asset.meta create mode 100644 Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Models/AllSceneValidationStep.cs create mode 100644 Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Models/AllSceneValidationStep.cs.meta delete mode 100644 Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingsTool.cs delete mode 100644 Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingsTool.cs.meta delete mode 100644 Assets/BetterValidation/Editor/EditorAddons/Utilities/GameObjectExtensions.cs rename Assets/BetterValidation/Editor/EditorAddons/{Utilities.meta => Utility.meta} (100%) rename Assets/BetterValidation/Editor/EditorAddons/{Utilities => Utility}/FoldoutHeaderGroupScope.cs (92%) rename Assets/BetterValidation/Editor/EditorAddons/{Utilities => Utility}/FoldoutHeaderGroupScope.cs.meta (100%) create mode 100644 Assets/BetterValidation/Editor/EditorAddons/Utility/GameObjectExtensions.cs rename Assets/BetterValidation/Editor/EditorAddons/{Utilities => Utility}/GameObjectExtensions.cs.meta (100%) rename Assets/BetterValidation/Editor/EditorAddons/{Utilities => Utility}/ToolsGUIUtility.cs (91%) rename Assets/BetterValidation/Editor/EditorAddons/{Utilities => Utility}/ToolsGUIUtility.cs.meta (100%) rename Assets/BetterValidation/Editor/EditorAddons/{Utilities/ValidationUtility.cs => Utility/ValidationAttributeUtility.cs} (76%) rename Assets/BetterValidation/Editor/EditorAddons/{Utilities/ValidationUtility.cs.meta => Utility/ValidationAttributeUtility.cs.meta} (100%) create mode 100644 Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationExtensions.cs rename Assets/BetterValidation/Editor/EditorAddons/{Utilities => Utility}/ValidationExtensions.cs.meta (100%) rename Assets/BetterValidation/Editor/EditorAddons/{Utilities/ValidationExtensions.cs => Utility/ValidationUtility.cs} (62%) create mode 100644 Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationUtility.cs.meta create mode 100644 Assets/BetterValidation/Editor/EditorAddons/Wrappers/MissingReferenceWrapper.cs create mode 100644 Assets/BetterValidation/Editor/EditorAddons/Wrappers/MissingReferenceWrapper.cs.meta create mode 100644 BetterValidation.Editor.csproj.DotSettings create mode 100644 BetterValidation.Runtime.csproj.DotSettings diff --git a/Assets/Better/Validation/Resources.meta b/Assets/Better/Validation/Resources.meta new file mode 100644 index 0000000..eb64e5e --- /dev/null +++ b/Assets/Better/Validation/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0ba2a324adf74a14a8b650413862005a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Better/Validation/Resources/ValidationSettings.asset b/Assets/Better/Validation/Resources/ValidationSettings.asset new file mode 100644 index 0000000..7a41a14 --- /dev/null +++ b/Assets/Better/Validation/Resources/ValidationSettings.asset @@ -0,0 +1,26 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 89a02ae4bedf42c29b1abd8ca87a5605, type: 3} + m_Name: ValidationSettings + m_EditorClassIdentifier: + _disableBuildValidation: 0 + _buildLoggingLevel: 1 + _validationSteps: + - rid: 1811633586712084480 + - rid: 1811633586712084481 + references: + version: 2 + RefIds: + - rid: 1811633586712084480 + type: {class: ProjectValidationStep, ns: Better.Validation.EditorAddons.PreBuildValidation, asm: BetterValidation.Editor} + - rid: 1811633586712084481 + type: {class: AllSceneValidationStep, ns: Better.Validation.EditorAddons.PreBuildValidation, asm: BetterValidation.Editor} diff --git a/Assets/Better/Validation/Resources/ValidationSettings.asset.meta b/Assets/Better/Validation/Resources/ValidationSettings.asset.meta new file mode 100644 index 0000000..0605f54 --- /dev/null +++ b/Assets/Better/Validation/Resources/ValidationSettings.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 30201084575d42145b7d0f6b470fcd3a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BetterValidation/Editor/BetterValidation.Editor.asmdef b/Assets/BetterValidation/Editor/BetterValidation.Editor.asmdef index 91a4da7..ce7e3b4 100644 --- a/Assets/BetterValidation/Editor/BetterValidation.Editor.asmdef +++ b/Assets/BetterValidation/Editor/BetterValidation.Editor.asmdef @@ -1,12 +1,17 @@ { - "name": "Better.Validation.Editor", - "rootNamespace": "Better.Validation", + "name": "BetterValidation.Editor", + "rootNamespace": "Better.Validation.EditorAddons", "references": [ - "GUID:441b78e90a9cf724ab41c6eed8c0b93d", - "GUID:19891d5296046644cbc12fcf3702cca3", + "GUID:01df13aca8d01e24a911bcc3e8277031", "GUID:443314a5a4e67c14a88ae223776b6554", + "GUID:1ac867a6259e45a1856740fe8f7623aa", "GUID:28da8d3b12e3efa47928e0c9070f853d", - "GUID:a59e3daedde9ca94bba45364d4ead25f" + "GUID:19891d5296046644cbc12fcf3702cca3", + "GUID:a59e3daedde9ca94bba45364d4ead25f", + "GUID:ecdd0819e3429eb44b13a432679a1135", + "GUID:1862b35041b066d42ab4d3caf773657b", + "GUID:af7fffdf1d83bc842b0f6e3a01efda16", + "GUID:441b78e90a9cf724ab41c6eed8c0b93d" ], "includePlatforms": [ "Editor" diff --git a/Assets/BetterValidation/Editor/EditorAddons/ContextResolver/AssetResolver.cs b/Assets/BetterValidation/Editor/EditorAddons/ContextResolver/AssetResolver.cs index 18205b2..3139393 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/ContextResolver/AssetResolver.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/ContextResolver/AssetResolver.cs @@ -1,13 +1,12 @@ -using Better.Validation.EditorAddons.Utilities; +using Better.Singletons.Runtime; +using Better.Validation.EditorAddons.Utility; using UnityEditor; using UnityEngine; namespace Better.Validation.EditorAddons.ContextResolver { - public class AssetResolver : IContextResolver + public class AssetPathResolver : PocoSingleton, IPathResolver { - public static IContextResolver Instance { get; } = new AssetResolver(); - public string Resolve(Object obj) { if (obj is GameObject gameObject) diff --git a/Assets/BetterValidation/Editor/EditorAddons/ContextResolver/IContextResolver.cs b/Assets/BetterValidation/Editor/EditorAddons/ContextResolver/IContextResolver.cs index 07e2ebd..3fff980 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/ContextResolver/IContextResolver.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/ContextResolver/IContextResolver.cs @@ -2,7 +2,7 @@ namespace Better.Validation.EditorAddons.ContextResolver { - public interface IContextResolver + public interface IPathResolver { public string Resolve(Object obj); } diff --git a/Assets/BetterValidation/Editor/EditorAddons/ContextResolver/SceneResolver.cs b/Assets/BetterValidation/Editor/EditorAddons/ContextResolver/SceneResolver.cs index a076556..534ad60 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/ContextResolver/SceneResolver.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/ContextResolver/SceneResolver.cs @@ -1,12 +1,11 @@ -using Better.Validation.EditorAddons.Utilities; +using Better.Singletons.Runtime; +using Better.Validation.EditorAddons.Utility; using UnityEngine; namespace Better.Validation.EditorAddons.ContextResolver { - public class SceneResolver : IContextResolver + public class SceneResolver : PocoSingleton, IPathResolver { - public static IContextResolver Instance { get; } = new SceneResolver(); - public string Resolve(Object obj) { return obj.FullPath(); diff --git a/Assets/BetterValidation/Editor/EditorAddons/Drawers/ValidationDrawer.cs b/Assets/BetterValidation/Editor/EditorAddons/Drawers/ValidationDrawer.cs index ce5434d..6e835dd 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Drawers/ValidationDrawer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Drawers/ValidationDrawer.cs @@ -1,10 +1,10 @@ using System.Reflection; -using Better.EditorTools.Attributes; -using Better.EditorTools.Drawers.Base; -using Better.EditorTools.Helpers; -using Better.EditorTools.Helpers.Caching; -using Better.Tools.Runtime.Attributes; -using Better.Validation.EditorAddons.Utilities; +using Better.EditorTools.EditorAddons.Attributes; +using Better.EditorTools.EditorAddons.Drawers.Base; +using Better.EditorTools.EditorAddons.Helpers; +using Better.EditorTools.EditorAddons.Helpers.Caching; +using Better.EditorTools.Runtime.Attributes; +using Better.Validation.EditorAddons.Utility; using Better.Validation.EditorAddons.Wrappers; using Better.Validation.Runtime.Attributes; using UnityEditor; @@ -15,7 +15,7 @@ namespace Better.Validation.EditorAddons.Drawers [MultiCustomPropertyDrawer(typeof(ValidationAttribute))] public class ValidationDrawer : MultiFieldDrawer { - private Cache> _validationResult = new Cache>(); + private CacheValue> _validationResult = new CacheValue>(); public ValidationDrawer(FieldInfo fieldInfo, MultiPropertyAttribute attribute) : base(fieldInfo, attribute) { @@ -23,7 +23,7 @@ public ValidationDrawer(FieldInfo fieldInfo, MultiPropertyAttribute attribute) : protected override bool PreDraw(ref Rect position, SerializedProperty property, GUIContent label) { - var cache = ValidateCachedProperties(property, ValidationUtility.Instance); + var cache = ValidateCachedProperties(property, ValidationAttributeUtility.Instance); var validationWrapper = cache.Value; var wrapper = validationWrapper.Wrapper; if (!cache.IsValid) diff --git a/Assets/BetterValidation/Editor/EditorAddons/Iteration/IterationData.cs b/Assets/BetterValidation/Editor/EditorAddons/Iteration/IterationData.cs index b22d7b7..6496511 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Iteration/IterationData.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Iteration/IterationData.cs @@ -8,15 +8,15 @@ public class IterationData { public Object Target { get; private set; } - public IContextResolver ContextResolver { get; private set; } + public IPathResolver PathResolver { get; private set; } public SerializedProperty Property { get; private set; } public SerializedObject Context { get; private set; } - public void SetResolver(IContextResolver context) + public void SetResolver(IPathResolver path) { - ContextResolver = context; + PathResolver = path; } public void SetTarget(Object target) diff --git a/Assets/BetterValidation/Editor/EditorAddons/Iteration/Iterator.cs b/Assets/BetterValidation/Editor/EditorAddons/Iteration/Iterator.cs index eea12dd..8faecb9 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Iteration/Iterator.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Iteration/Iterator.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; +using Better.Extensions.Runtime; using Better.Validation.EditorAddons.ContextResolver; -using Better.Validation.EditorAddons.Utilities; +using Better.Validation.EditorAddons.Utility; using Better.Validation.EditorAddons.Wrappers; using UnityEditor; using UnityEngine; @@ -9,21 +10,26 @@ namespace Better.Validation.EditorAddons.Iteration { public static class Iterator { - private static IContextResolver _context; + private static IPathResolver _path; private static readonly IterationData CacheData = new IterationData(); public delegate IEnumerable OnPropertyIteration(IterationData commandData); - public static void SetContext(IContextResolver context) + public static void SetContext(IPathResolver path) { - _context = context; - CacheData.SetResolver(context); + _path = path; + CacheData.SetResolver(path); } - public static List ObjectIteration(Object go, OnPropertyIteration onPropertyIteration) + public static List ObjectIteration(Object reference, OnPropertyIteration onPropertyIteration) { - var gameObject = go as GameObject; - var components = gameObject ? gameObject.GetComponents() : new[] { go }; + if (reference.IsNullOrDestroyed()) + { + return new List(); + } + + var gameObject = reference as GameObject; + var components = gameObject ? gameObject.GetComponents() : new[] { reference }; var commandData = new List(); EditorUtility.DisplayProgressBar("Validating components...", "", 0); @@ -32,9 +38,9 @@ public static List ObjectIteration(Object go, OnPropertyI var obj = components[index]; if (!obj) { - CacheData.SetTarget(go); + CacheData.SetTarget(reference); var missingReference = new ValidationCommandData(CacheData, new MissingComponentWrapper(gameObject)); - missingReference.SetResultCompiler((data, result) => $"Missing Component on GameObject: {_context.Resolve(data.Target)}"); + missingReference.SetResultCompiler((data, result) => $"Missing Component on GameObject: {_path.Resolve(data.Target)}"); missingReference.Revalidate(); commandData.Add(missingReference); continue; @@ -86,7 +92,5 @@ public static List ObjectsIteration(IReadOnlyList EditorUtility.ClearProgressBar(); return list; } - - } } \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Iteration/IteratorFilter.cs b/Assets/BetterValidation/Editor/EditorAddons/Iteration/IteratorFilter.cs index 0ebe6e5..f12c309 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Iteration/IteratorFilter.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Iteration/IteratorFilter.cs @@ -1,9 +1,10 @@ using System.Collections.Generic; -using Better.EditorTools; -using Better.EditorTools.Drawers.Base; -using Better.EditorTools.Helpers.Caching; +using System.Text; +using Better.EditorTools.EditorAddons.Drawers.Base; +using Better.EditorTools.EditorAddons.Helpers.Caching; +using Better.Extensions.EditorAddons; using Better.Extensions.Runtime; -using Better.Validation.EditorAddons.Utilities; +using Better.Validation.EditorAddons.Utility; using Better.Validation.EditorAddons.Wrappers; using Better.Validation.Runtime.Attributes; @@ -11,7 +12,7 @@ namespace Better.Validation.EditorAddons.Iteration { public static class IteratorFilter { - private class LocalCache : Cache> + private class LocalCache : CacheValue> { } @@ -26,11 +27,16 @@ public static IEnumerable PropertyIterationWithAttributes var list = data.Property.GetAttributes(); if (fieldInfo == null || list == null) return null; - var fieldType = fieldInfo.FieldInfo.GetFieldOrElementType(); + var fieldType = fieldInfo.FieldInfo.FieldType; + if (fieldType.IsArrayOrList()) + { + fieldType = fieldType.GetCollectionElementType(); + } + var dataList = new List(); foreach (var validationAttribute in list) { - Wrappers.ValidateCachedProperties(CacheField, data.Property, fieldType, validationAttribute.GetType(), ValidationUtility.Instance); + ValidateCachedPropertiesUtility.Validate(Wrappers, CacheField, data.Property, fieldType, validationAttribute.GetType(), ValidationAttributeUtility.Instance); var fieldValue = CacheField.Value; if (fieldValue == null) @@ -81,10 +87,17 @@ private static string ObjectCompiler(ValidationCommandData commandData, string r var property = commandData.Property; var path = property.IsArrayElement() ? property.GetArrayPath() : property.displayName; var target = commandData.Target; - var str = - $"Validation failed with: {result}.\nPath: {commandData.ContextResolver.Resolve(target)}. Component: {target.GetType().Name}, Property: {path}"; - - return str; + var resolvedPath = commandData.PathResolver.Resolve(target); + var typeName = target.GetType().Name; + + var stringBuilder = new StringBuilder(); + stringBuilder.AppendFormat("Validation failed with: {0}.", result); + stringBuilder.AppendLine(); + stringBuilder.AppendFormat("Path: {0}.", resolvedPath); + stringBuilder.AppendLine(); + stringBuilder.AppendFormat("Component: {0}, Property: {1}", typeName, path); + + return stringBuilder.ToString(); } } } \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/MenuItems.cs b/Assets/BetterValidation/Editor/EditorAddons/MenuItems.cs index a049820..11473c8 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/MenuItems.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/MenuItems.cs @@ -6,7 +6,7 @@ namespace Better.Validation.EditorAddons { public static class MenuItems { - [MenuItem(ValidationSettingsTool.MenuItemPrefix + "/Open Validation Window", false, 50)] + [MenuItem(ValidationSettingProvider.Path + "/Open Validation Window", false, 50)] private static void ValidateInProject() { ValidationWindow.OpenWindow(); diff --git a/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Interfaces/IBuildValidationStep.cs b/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Interfaces/IBuildValidationStep.cs index 14222cc..468cc7d 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Interfaces/IBuildValidationStep.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Interfaces/IBuildValidationStep.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; -namespace Better.Validation.EditorAddons.PreBuildValidation.Interfaces +namespace Better.Validation.EditorAddons.PreBuildValidation { public interface IBuildValidationStep { - public List GatherValidationData(); + public List GatherValidationData(ValidatorCommands commands); } } \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Models/AllSceneValidationStep.cs b/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Models/AllSceneValidationStep.cs new file mode 100644 index 0000000..9dbdd7f --- /dev/null +++ b/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Models/AllSceneValidationStep.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; + +namespace Better.Validation.EditorAddons.PreBuildValidation +{ + [Serializable] + public class AllSceneValidationStep : IBuildValidationStep + { + public List GatherValidationData(ValidatorCommands commands) + { + return commands.ValidateAttributesInAllScenes(); + } + } +} \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Models/AllSceneValidationStep.cs.meta b/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Models/AllSceneValidationStep.cs.meta new file mode 100644 index 0000000..195d76d --- /dev/null +++ b/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Models/AllSceneValidationStep.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c977713bdae94df39e62b9599cc8d37e +timeCreated: 1709473154 \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Models/ProjectValidationStep.cs b/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Models/ProjectValidationStep.cs index ec180e1..e628c76 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Models/ProjectValidationStep.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/Models/ProjectValidationStep.cs @@ -1,26 +1,14 @@ using System; using System.Collections.Generic; -using Better.Validation.EditorAddons.PreBuildValidation.Interfaces; -namespace Better.Validation.EditorAddons.PreBuildValidation.Models +namespace Better.Validation.EditorAddons.PreBuildValidation { [Serializable] public class ProjectValidationStep : IBuildValidationStep { - public List GatherValidationData() + public List GatherValidationData(ValidatorCommands commands) { - 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/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/ValidationBuildProcess.cs b/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/ValidationBuildProcess.cs index 007343b..2fbc636 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/ValidationBuildProcess.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/PreBuildValidation/ValidationBuildProcess.cs @@ -2,8 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using Better.EditorTools.SettingsTools; -using Better.Tools.Runtime; +using Better.Internal.Core.Runtime; using Better.Validation.EditorAddons.Settings; using Better.Validation.EditorAddons.WindowModule; using Better.Validation.Runtime.Attributes; @@ -21,25 +20,37 @@ public class ValidationBuildProcess : IPreprocessBuildWithReport public ValidationBuildProcess() { - _settings = Resources.Load(nameof(ValidationSettings)); + _settings = ValidationSettings.Instance; } public void OnPreprocessBuild(BuildReport report) { if(_settings.DisableBuildValidation) return; + var validationCommands = new ValidatorCommands(); var commandDatas = new List(); var validationSteps = _settings.GetSteps(); foreach (var buildValidationStep in validationSteps) { - commandDatas.AddRange(buildValidationStep.GatherValidationData()); + commandDatas.AddRange(buildValidationStep.GatherValidationData(validationCommands)); } commandDatas = commandDatas.Where(x => x.Type >= _settings.BuildLoggingLevel).ToList(); if (!commandDatas.Any()) return; + var str = CreateDialogMessage(commandDatas); + EditorApplication.Beep(); + if (!EditorUtility.DisplayDialog("Validation failed", str.ToString(), "Ignore", "Resolve")) + { + ValidationWindow.OpenWindow(commandDatas); + throw new BuildFailedException("Pre build validation failed"); + } + } + + private static StringBuilder CreateDialogMessage(List commandDatas) + { var str = new StringBuilder("Pre build validation failed."); - str.Append(Environment.NewLine); + str.AppendLine(); str.AppendLine("There are:"); var values = (ValidationType[])Enum.GetValues(typeof(ValidationType)); for (var index = values.Length - 1; index >= 0; index--) @@ -48,19 +59,14 @@ public void OnPreprocessBuild(BuildReport report) var count = commandDatas.Count(x => x.Type == value); var appendix = count > 1 ? "s" : ""; str.AppendFormat("- {0} {1}{2}", count, value.ToString(), appendix); - str.Append(Environment.NewLine); + str.AppendLine(); } 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})", BetterEditorDefines.BetterPrefix, ProjectSettingsToolsContainer.Instance.NamespacePrefix); - EditorApplication.Beep(); - if (!EditorUtility.DisplayDialog("Validation failed", str.ToString(), "Ignore", "Resolve")) - { - ValidationWindow.OpenWindow(commandDatas); - throw new BuildFailedException("Pre build validation failed"); - } + str.AppendLine(); + str.AppendLine(); + str.AppendFormat("(You can disable validation in Edit > Project Settings > {0})", ValidationSettingProvider.Path.Replace("/", " > ")); + return str; } } } \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Settings/BuildValidationStepsDrawer.cs b/Assets/BetterValidation/Editor/EditorAddons/Settings/BuildValidationStepsDrawer.cs index 88107c0..ffdfad3 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Settings/BuildValidationStepsDrawer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Settings/BuildValidationStepsDrawer.cs @@ -1,9 +1,10 @@ using System; -using Better.EditorTools; -using Better.EditorTools.Helpers; -using Better.EditorTools.Helpers.DropDown; +using System.Linq; +using Better.EditorTools.EditorAddons.Helpers; +using Better.EditorTools.EditorAddons.Helpers.DropDown; +using Better.Extensions.EditorAddons; using Better.Extensions.Runtime; -using Better.Validation.EditorAddons.PreBuildValidation.Interfaces; +using Better.Validation.EditorAddons.PreBuildValidation; using UnityEditor; using UnityEditorInternal; using UnityEngine; @@ -22,7 +23,7 @@ internal class BuildValidationStepsDrawer public BuildValidationStepsDrawer(SerializedObject settingsObject, SerializedProperty stepsProperty) { - _types = typeof(IBuildValidationStep).GetAllInheritedType(); + _types = typeof(IBuildValidationStep).GetAllInheritedTypesWithoutUnityObject().ToArray(); _stepsProperty = stepsProperty; _reorderableList = new ReorderableList(settingsObject, _stepsProperty, true, true, true, true) @@ -46,7 +47,6 @@ private void HeaderCallback(Rect rect) private void DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused) { - var property = _stepsProperty.GetArrayElementAtIndex(index); var type = property.GetManagedType(); diff --git a/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingProvider.cs b/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingProvider.cs index 6f76daf..491a890 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingProvider.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingProvider.cs @@ -1,29 +1,23 @@ using System.Collections.Generic; -using Better.EditorTools.SettingsTools; -using Better.Tools.Runtime; +using Better.Internal.Core.Runtime; +using Better.ProjectSettings.EditorAddons; using UnityEditor; namespace Better.Validation.EditorAddons.Settings { - internal class ValidationSettingProvider : ProjectSettingsProvider + internal class ValidationSettingProvider : DefaultProjectSettingsProvider { - private readonly Editor _editor; - - public ValidationSettingProvider() : base(ProjectSettingsToolsContainer.Instance, SettingsScope.Project) + public const string Path = PrefixConstants.BetterPrefix + "/" + nameof(Validation); + + public ValidationSettingProvider() : base(Path) { keywords = new HashSet(new[] { "Better", "Validation", "Warnings", "Ignore" }); - _editor = Editor.CreateEditor(_settings); } - [MenuItem(ValidationSettingsTool.MenuItemPrefix + "/" + BetterEditorDefines.HighlightPrefix, false, 999)] + [MenuItem(Path + "/" + PrefixConstants.HighlightPrefix, false, 999)] private static void Highlight() { - SettingsService.OpenProjectSettings(ProjectSettingsToolsContainer.Instance.ProjectSettingKey); - } - - protected override void DrawGUI() - { - _editor.OnInspectorGUI(); + SettingsService.OpenProjectSettings(ProjectPath + Path); } } } \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettings.cs b/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettings.cs index 0db41ad..3d7b528 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettings.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettings.cs @@ -1,27 +1,29 @@ using System.Collections.Generic; -using Better.Tools.Runtime.Settings; -using Better.Validation.EditorAddons.PreBuildValidation.Interfaces; -using Better.Validation.EditorAddons.PreBuildValidation.Models; +using Better.Internal.Core.Runtime; +using Better.ProjectSettings.Runtime; +using Better.Singletons.Runtime.Attributes; +using Better.Validation.EditorAddons.PreBuildValidation; using Better.Validation.Runtime.Attributes; using UnityEngine; namespace Better.Validation.EditorAddons.Settings { - public class ValidationSettings : ProjectSettings + [ScriptableCreate(PrefixConstants.BetterPrefix + "/" + nameof(Validation))] + public class ValidationSettings : ScriptableSettings { - [SerializeField] private bool disableBuildValidation; - [SerializeField] private ValidationType buildLoggingLevel = ValidationType.Warning; + [SerializeField] private bool _disableBuildValidation; + [SerializeField] private ValidationType _buildLoggingLevel = ValidationType.Warning; - [SerializeReference] private IBuildValidationStep[] validationSteps = new IBuildValidationStep[] + [SerializeReference] private IBuildValidationStep[] _validationSteps = new IBuildValidationStep[] { new ProjectValidationStep(), new AllSceneValidationStep() }; - public ValidationType BuildLoggingLevel => buildLoggingLevel; + public ValidationType BuildLoggingLevel => _buildLoggingLevel; - public bool DisableBuildValidation => disableBuildValidation; + public bool DisableBuildValidation => _disableBuildValidation; - public List GetSteps() + public IReadOnlyList GetSteps() { - return new List(validationSteps); + return _validationSteps; } } } \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingsEditor.cs b/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingsEditor.cs index 1630f1f..392c5b7 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingsEditor.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingsEditor.cs @@ -1,7 +1,4 @@ -using System; -using Better.EditorTools.Helpers; -using UnityEditor; -using UnityEditorInternal; +using UnityEditor; using Object = UnityEngine.Object; namespace Better.Validation.EditorAddons.Settings @@ -17,9 +14,9 @@ public class ValidationSettingsEditor : Editor private void OnEnable() { - _disableBuildProperty = serializedObject.FindProperty("disableBuildValidation"); - _logLevelProperty = serializedObject.FindProperty("buildLoggingLevel"); - _stepsProperty = serializedObject.FindProperty("validationSteps"); + _disableBuildProperty = serializedObject.FindProperty("_disableBuildValidation"); + _logLevelProperty = serializedObject.FindProperty("_buildLoggingLevel"); + _stepsProperty = serializedObject.FindProperty("_validationSteps"); _drawer = new BuildValidationStepsDrawer(serializedObject, _stepsProperty); _target = serializedObject.targetObject; } diff --git a/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingsTool.cs b/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingsTool.cs deleted file mode 100644 index c320f2e..0000000 --- a/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingsTool.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Better.EditorTools.SettingsTools; -using Better.Tools.Runtime; -using UnityEditor; - -namespace Better.Validation.EditorAddons.Settings -{ - public class ValidationSettingsTool : ProjectSettingsTools - { - private const string SettingMenuItem = nameof(Validation); - public const string MenuItemPrefix = BetterEditorDefines.BetterPrefix + "/" + SettingMenuItem; - - public ValidationSettingsTool() : base(SettingMenuItem, SettingMenuItem, new string[] - { BetterEditorDefines.BetterPrefix, SettingMenuItem, nameof(Editor), BetterEditorDefines.ResourcesPrefix }) - { - } - } -} \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingsTool.cs.meta b/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingsTool.cs.meta deleted file mode 100644 index ca76a6a..0000000 --- a/Assets/BetterValidation/Editor/EditorAddons/Settings/ValidationSettingsTool.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: e5c301f633d3430b8b58f41174cb7b73 -timeCreated: 1686840799 \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities/GameObjectExtensions.cs b/Assets/BetterValidation/Editor/EditorAddons/Utilities/GameObjectExtensions.cs deleted file mode 100644 index d0543ac..0000000 --- a/Assets/BetterValidation/Editor/EditorAddons/Utilities/GameObjectExtensions.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System.Collections.Generic; -using Better.Extensions.Runtime; -using UnityEditor; -using UnityEngine; -using UnityEngine.SceneManagement; -using Object = UnityEngine.Object; - -namespace Better.Validation.EditorAddons.Utilities -{ - public static class GameObjectExtensions - { - private static readonly IReadOnlyList Empty = new List(); - - public static string FullPath(this GameObject go) - { - return go.transform.parent.IsNullOrDestroyed() - ? go.name - : FullPath(go.transform.parent.gameObject) + "/" + go.name; - } - - public static string FullPath(this Object obj) - { - if (!PrefabUtility.IsPartOfPrefabAsset(obj)) - { - switch (obj) - { - case GameObject go: - return FullPath(go); - case Component component: - return FullPath(component.gameObject); - } - } - - return AssetDatabase.GetAssetPath(obj) + "/" + obj.name; - } - - public static string FullPathNoRoot(this GameObject go) - { - return go.transform.parent.IsNullOrDestroyed() - ? string.Empty - : FullPathNoRoot(go.transform.parent.gameObject) + "/" + go.name; - } - - public static string FullPathNoRoot(this Object obj) - { - if (!PrefabUtility.IsPartOfPrefabAsset(obj)) - { - switch (obj) - { - case GameObject go: - return FullPathNoRoot(go); - case Component component: - return FullPathNoRoot(component.gameObject); - } - } - - return AssetDatabase.GetAssetPath(obj) + "/" + obj.name; - } - - public static IReadOnlyList GetAllChildren(this GameObject root) - { - if (root.IsNullOrDestroyed()) return Empty; - var children = new List(); - - var queue = new Queue(); - queue.Enqueue(root.transform); - while (queue.Count > 0) - { - var transform = queue.Dequeue(); - - children.Add(transform.gameObject); - - foreach (Transform item in transform) - queue.Enqueue(item); - } - - return children; - } - - public static IReadOnlyList GetAllChildren(this Object root) - { - if (root.IsNullOrDestroyed()) return Empty; - if (root is GameObject gameObject) return gameObject.GetAllChildren(); - - return new[] { root }; - } - } -} \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities.meta b/Assets/BetterValidation/Editor/EditorAddons/Utility.meta similarity index 100% rename from Assets/BetterValidation/Editor/EditorAddons/Utilities.meta rename to Assets/BetterValidation/Editor/EditorAddons/Utility.meta diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities/FoldoutHeaderGroupScope.cs b/Assets/BetterValidation/Editor/EditorAddons/Utility/FoldoutHeaderGroupScope.cs similarity index 92% rename from Assets/BetterValidation/Editor/EditorAddons/Utilities/FoldoutHeaderGroupScope.cs rename to Assets/BetterValidation/Editor/EditorAddons/Utility/FoldoutHeaderGroupScope.cs index f04f000..42bc231 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Utilities/FoldoutHeaderGroupScope.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Utility/FoldoutHeaderGroupScope.cs @@ -3,7 +3,7 @@ using UnityEditor; using UnityEngine; -namespace Better.Validation.EditorAddons.Utilities +namespace Better.Validation.EditorAddons.Utility { public class FoldoutHeaderGroupScope : GUI.Scope { diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities/FoldoutHeaderGroupScope.cs.meta b/Assets/BetterValidation/Editor/EditorAddons/Utility/FoldoutHeaderGroupScope.cs.meta similarity index 100% rename from Assets/BetterValidation/Editor/EditorAddons/Utilities/FoldoutHeaderGroupScope.cs.meta rename to Assets/BetterValidation/Editor/EditorAddons/Utility/FoldoutHeaderGroupScope.cs.meta diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utility/GameObjectExtensions.cs b/Assets/BetterValidation/Editor/EditorAddons/Utility/GameObjectExtensions.cs new file mode 100644 index 0000000..0b8fa0c --- /dev/null +++ b/Assets/BetterValidation/Editor/EditorAddons/Utility/GameObjectExtensions.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using Better.Extensions.Runtime; +using UnityEditor; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace Better.Validation.EditorAddons.Utility +{ + public static class GameObjectExtensions + { + private static readonly IReadOnlyList Empty = new List(); + + public static string FullPath(this GameObject self) + { + if (self.IsNullOrDestroyed()) + { + DebugUtility.LogException(nameof(self)); + return string.Empty; + } + + return self.transform.parent.IsNullOrDestroyed() + ? self.name + : FullPath(self.transform.parent.gameObject) + "/" + self.name; + } + + public static string FullPath(this Object self) + { + if (self.IsNullOrDestroyed()) + { + DebugUtility.LogException(nameof(self)); + return string.Empty; + } + + if (!PrefabUtility.IsPartOfPrefabAsset(self)) + { + switch (self) + { + case GameObject go: + return FullPath(go); + case Component component: + return FullPath(component.gameObject); + } + } + + return AssetDatabase.GetAssetPath(self) + "/" + self.name; + } + + public static string FullPathNoRoot(this GameObject self) + { + if (self.IsNullOrDestroyed()) + { + DebugUtility.LogException(nameof(self)); + return string.Empty; + } + + return self.transform.parent.IsNullOrDestroyed() + ? string.Empty + : FullPathNoRoot(self.transform.parent.gameObject) + "/" + self.name; + } + + public static string FullPathNoRoot(this Object self) + { + if (self.IsNullOrDestroyed()) + { + DebugUtility.LogException(nameof(self)); + return string.Empty; + } + + if (!PrefabUtility.IsPartOfPrefabAsset(self)) + { + switch (self) + { + case GameObject go: + return FullPathNoRoot(go); + case Component component: + return FullPathNoRoot(component.gameObject); + } + } + + return AssetDatabase.GetAssetPath(self) + "/" + self.name; + } + + public static IReadOnlyList GetAllChildren(this GameObject self) + { + if (self.IsNullOrDestroyed()) + { + DebugUtility.LogException(nameof(self)); + return Empty; + } + + var children = new List(); + + var queue = new Queue(); + queue.Enqueue(self.transform); + while (queue.Count > 0) + { + var transform = queue.Dequeue(); + + children.Add(transform.gameObject); + + foreach (Transform item in transform) + queue.Enqueue(item); + } + + return children; + } + + public static IReadOnlyList GetAllChildren(this Object self) + { + if (self.IsNullOrDestroyed()) + { + DebugUtility.LogException(nameof(self)); + return Empty; + } + + if (self is GameObject gameObject) return gameObject.GetAllChildren(); + + return new[] { self }; + } + } +} \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities/GameObjectExtensions.cs.meta b/Assets/BetterValidation/Editor/EditorAddons/Utility/GameObjectExtensions.cs.meta similarity index 100% rename from Assets/BetterValidation/Editor/EditorAddons/Utilities/GameObjectExtensions.cs.meta rename to Assets/BetterValidation/Editor/EditorAddons/Utility/GameObjectExtensions.cs.meta diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs b/Assets/BetterValidation/Editor/EditorAddons/Utility/ToolsGUIUtility.cs similarity index 91% rename from Assets/BetterValidation/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs rename to Assets/BetterValidation/Editor/EditorAddons/Utility/ToolsGUIUtility.cs index a58a4c4..755e444 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Utility/ToolsGUIUtility.cs @@ -1,10 +1,10 @@ -using Better.EditorTools.Helpers; +using Better.EditorTools.EditorAddons.Helpers; using UnityEditor; using UnityEngine; -namespace Better.Validation.EditorAddons.Utilities +namespace Better.Validation.EditorAddons.Utility { - public static class ToolsGUIUtility + internal static class ToolsGUIUtility { public static readonly GUIStyle SelectionStyle = new GUIStyle("TV Selection") { @@ -42,7 +42,7 @@ public static int Toolbar(int groupID, string[] groupNames, out bool changed) private static void DrawVerticalLineFull(Color color, int thickness = 1, int padding = 10) { - Rect r = EditorGUILayout.GetControlRect(GUILayout.Width(padding + thickness)); + var r = EditorGUILayout.GetControlRect(GUILayout.Width(padding + thickness)); r.width = thickness; r.x -= 4; r.y -= 2; diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs.meta b/Assets/BetterValidation/Editor/EditorAddons/Utility/ToolsGUIUtility.cs.meta similarity index 100% rename from Assets/BetterValidation/Editor/EditorAddons/Utilities/ToolsGUIUtility.cs.meta rename to Assets/BetterValidation/Editor/EditorAddons/Utility/ToolsGUIUtility.cs.meta diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationUtility.cs b/Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationAttributeUtility.cs similarity index 76% rename from Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationUtility.cs rename to Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationAttributeUtility.cs index 3f5d6c6..98941d0 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationUtility.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationAttributeUtility.cs @@ -1,14 +1,14 @@ using System; using System.Collections.Generic; -using Better.EditorTools.Comparers; -using Better.EditorTools.Drawers.Base; -using Better.EditorTools.Utilities; +using Better.EditorTools.EditorAddons.Comparers; +using Better.EditorTools.EditorAddons.Utilities; +using Better.EditorTools.EditorAddons.WrappersTypeCollection; using Better.Validation.EditorAddons.Wrappers; using Better.Validation.Runtime.Attributes; -namespace Better.Validation.EditorAddons.Utilities +namespace Better.Validation.EditorAddons.Utility { - public class ValidationUtility : BaseUtility + public class ValidationAttributeUtility : BaseUtility { protected override BaseWrappersTypeCollection GenerateCollection() { diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationUtility.cs.meta b/Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationAttributeUtility.cs.meta similarity index 100% rename from Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationUtility.cs.meta rename to Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationAttributeUtility.cs.meta diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationExtensions.cs b/Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationExtensions.cs new file mode 100644 index 0000000..276efa9 --- /dev/null +++ b/Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationExtensions.cs @@ -0,0 +1,21 @@ +using System; +using Better.EditorTools.EditorAddons.Helpers; +using Better.Validation.Runtime.Attributes; + + +namespace Better.Validation.EditorAddons.Utility +{ + public static class ValidationExtensions + { + public static IconType GetIconType(this ValidationType dataType) + { + return dataType switch + { + ValidationType.Error => IconType.ErrorMessage, + ValidationType.Warning => IconType.WarningMessage, + ValidationType.Info => IconType.InfoMessage, + _ => throw new ArgumentOutOfRangeException(nameof(dataType), dataType, null) + }; + } + } +} \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationExtensions.cs.meta b/Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationExtensions.cs.meta similarity index 100% rename from Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationExtensions.cs.meta rename to Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationExtensions.cs.meta diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationExtensions.cs b/Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationUtility.cs similarity index 62% rename from Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationExtensions.cs rename to Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationUtility.cs index f01598c..072731f 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Utilities/ValidationExtensions.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationUtility.cs @@ -1,74 +1,54 @@ using System; using System.Collections.Generic; -using System.IO; -using Better.EditorTools.Helpers; -using Better.Validation.Runtime.Attributes; +using System.Linq; +using Better.Extensions.Runtime; using UnityEditor; using UnityEditor.SceneManagement; 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 +namespace Better.Validation.EditorAddons.Utility { - public static class ValidationExtensions + public static class ValidationUtility { - public static IconType GetIconType(this ValidationType dataType) + public static void OpenReference(UnityEngine.Object reference) { - return dataType switch + if (reference.IsNullOrDestroyed()) { - ValidationType.Error => IconType.ErrorMessage, - ValidationType.Warning => IconType.WarningMessage, - ValidationType.Info => IconType.InfoMessage, - _ => throw new ArgumentOutOfRangeException(nameof(dataType), dataType, null) - }; - } + DebugUtility.LogException(nameof(reference)); + return; + } - public static void OpenReference(UnityEngine.Object reference) - { if (reference is Component component) { var transform = component.transform; if (PrefabUtility.IsPartOfPrefabAsset(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 prefabRootTransform = stage.prefabContentsRoot.transform; var indexes = GetParentIndices(transform); transform = GetChildBySiblingIndices(prefabRootTransform, indexes); } else { - int countLoaded = SceneManager.sceneCount; - Scene[] loadedScenes = new Scene[countLoaded]; + var countLoaded = SceneManager.sceneCount; + var loadedScenes = new Scene[countLoaded]; - for (int i = 0; i < countLoaded; i++) + for (var i = 0; i < countLoaded; i++) { loadedScenes[i] = SceneManager.GetSceneAt(i); } - if (loadedScenes.Contains(component.gameObject.scene)) + var gameObject = component.gameObject; + if (loadedScenes.Contains(gameObject.scene)) { - EditorSceneManager.SetActiveScene(component.gameObject.scene); + EditorSceneManager.SetActiveScene(gameObject.scene); } else { - EditorSceneManager.OpenScene(component.gameObject.scene.path); + EditorSceneManager.OpenScene(gameObject.scene.path); } } @@ -81,9 +61,15 @@ public static void OpenReference(UnityEngine.Object reference) EditorGUIUtility.PingObject(reference); } } - + private static List GetParentIndices(Transform instance) { + if (instance.IsNullOrDestroyed()) + { + DebugUtility.LogException(nameof(instance)); + return new List(); + } + var siblingIndices = new List(); var parent = instance.parent; @@ -104,7 +90,7 @@ private static List GetParentIndices(Transform instance) return siblingIndices; } - private static Transform GetChildBySiblingIndices(Transform transform, List siblingIndices) + private static Transform GetChildBySiblingIndices(Transform transform, IReadOnlyList siblingIndices) { var child = transform; for (var i = siblingIndices.Count - 1; i >= 0; i--) @@ -123,5 +109,6 @@ private static Transform GetChildBySiblingIndices(Transform transform, List return child; } + } } \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationUtility.cs.meta b/Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationUtility.cs.meta new file mode 100644 index 0000000..d0fbe14 --- /dev/null +++ b/Assets/BetterValidation/Editor/EditorAddons/Utility/ValidationUtility.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6d7c9b07c05d402da3e724c7fa9f5c61 +timeCreated: 1709763659 \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/ValidationCommandData.cs b/Assets/BetterValidation/Editor/EditorAddons/ValidationCommandData.cs index 14a8aed..b16373e 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/ValidationCommandData.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/ValidationCommandData.cs @@ -1,7 +1,6 @@ using System; using Better.Validation.EditorAddons.ContextResolver; using Better.Validation.EditorAddons.Iteration; -using Better.Validation.EditorAddons.Utilities; using Better.Validation.EditorAddons.Wrappers; using Better.Validation.Runtime.Attributes; using UnityEditor; @@ -12,7 +11,7 @@ namespace Better.Validation.EditorAddons public class ValidationCommandData { private Func _compiler; - public IContextResolver ContextResolver { get; private set; } + public IPathResolver PathResolver { get; private set; } public Object Target { get; private set; } public SerializedObject Context { get; } public SerializedProperty Property { get; private set; } @@ -23,7 +22,7 @@ public class ValidationCommandData public ValidationCommandData(IterationData data, ValidationWrapper wrapper) { - ContextResolver = data.ContextResolver; + PathResolver = data.PathResolver; Context = data.Context; Property = data.Property; Target = data.Target; diff --git a/Assets/BetterValidation/Editor/EditorAddons/ValidatorCommands.cs b/Assets/BetterValidation/Editor/EditorAddons/ValidatorCommands.cs index 7b02d46..4ae7223 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/ValidatorCommands.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/ValidatorCommands.cs @@ -1,9 +1,8 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Better.Validation.EditorAddons.ContextResolver; using Better.Validation.EditorAddons.Iteration; -using Better.Validation.EditorAddons.Utilities; +using Better.Validation.EditorAddons.Utility; using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; @@ -17,11 +16,10 @@ public class ValidatorCommands public List ValidateAttributesInProject() { var allAssets = AssetDatabase.GetAllAssetPaths(); - var objs = allAssets.SelectMany(a => - AssetDatabase.LoadAssetAtPath(a).GetAllChildren().Where(file => - file is ScriptableObject || file is GameObject)).ToArray(); + var objects = allAssets.Select(AssetDatabase.LoadAssetAtPath).Where(obj => obj); + var objs = objects.SelectMany(obj => obj.GetAllChildren().Where(file => file is ScriptableObject || file is GameObject)).ToArray(); - Iterator.SetContext(AssetResolver.Instance); + Iterator.SetContext(AssetPathResolver.Instance); return Iterator.ObjectsIteration(objs, IteratorFilter.PropertyIterationWithAttributes); } @@ -29,8 +27,9 @@ public List ValidateAttributesInCurrentScene() { var scene = SceneManager.GetActiveScene(); Iterator.SetContext(SceneResolver.Instance); - return Iterator.ObjectsIteration(scene.GetRootGameObjects().SelectMany(x => x.GetAllChildren()).ToList(), - IteratorFilter.PropertyIterationWithAttributes); + + var objects = scene.GetRootGameObjects().SelectMany(x => x.GetAllChildren()).ToList(); + return Iterator.ObjectsIteration(objects, IteratorFilter.PropertyIterationWithAttributes); } public List ValidateAttributesInAllScenes() @@ -40,7 +39,9 @@ public List ValidateAttributesInAllScenes() foreach (var scene in EditorBuildSettings.scenes.Where(s => s.enabled)) { var sceneReference = EditorSceneManager.OpenScene(scene.path); - list.AddRange(Iterator.ObjectsIteration(sceneReference.GetRootGameObjects(), IteratorFilter.PropertyIterationWithAttributes)); + var objects = sceneReference.GetRootGameObjects(); + + list.AddRange(Iterator.ObjectsIteration(objects, IteratorFilter.PropertyIterationWithAttributes)); } return list; @@ -53,7 +54,9 @@ public List FindMissingInAllScenes() foreach (var scene in EditorBuildSettings.scenes.Where(s => s.enabled)) { var sceneReference = EditorSceneManager.OpenScene(scene.path); - list.AddRange(Iterator.ObjectsIteration(sceneReference.GetRootGameObjects(), IteratorFilter.MissingPropertyIteration)); + var objects = sceneReference.GetRootGameObjects(); + + list.AddRange(Iterator.ObjectsIteration(objects, IteratorFilter.MissingPropertyIteration)); } return list; @@ -68,7 +71,8 @@ public List FindMissingReferencesInCurrentScene() var list = new List(); for (var i = 0; i < countLoaded; i++) { - var data = Iterator.ObjectsIteration(SceneManager.GetSceneAt(i).GetRootGameObjects(), IteratorFilter.MissingPropertyIteration); + var objects = SceneManager.GetSceneAt(i).GetRootGameObjects(); + var data = Iterator.ObjectsIteration(objects, IteratorFilter.MissingPropertyIteration); list.AddRange(data); } @@ -78,9 +82,10 @@ public List FindMissingReferencesInCurrentScene() public List FindMissingReferencesInProject() { var allAssets = AssetDatabase.GetAllAssetPaths(); - var objs = allAssets.Select(a => AssetDatabase.LoadAssetAtPath(a, typeof(GameObject)) as GameObject).Where(a => a != null).ToArray(); + Iterator.SetContext(AssetPathResolver.Instance); + + var objs = allAssets.Select(a => AssetDatabase.LoadAssetAtPath(a, typeof(GameObject)) as GameObject).Where(obj => obj).ToArray(); - Iterator.SetContext(AssetResolver.Instance); return Iterator.ObjectsIteration(objs, IteratorFilter.MissingPropertyIteration); } } diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/CollectionDrawer.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/CollectionDrawer.cs index 0bfbc91..52c9dec 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/CollectionDrawer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/CollectionDrawer.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -using Better.EditorTools.Helpers; -using Better.Validation.EditorAddons.Utilities; +using Better.EditorTools.EditorAddons.Helpers; +using Better.Validation.EditorAddons.Utility; using UnityEditor; using UnityEngine; @@ -8,6 +8,7 @@ namespace Better.Validation.EditorAddons.WindowModule.CollectionDrawing { public abstract class CollectionDrawer { + private const string ScriptIconName = "cs Script Icon"; protected ValidationCommandData _currentItem = null; public abstract int Count { get; } @@ -64,21 +65,21 @@ protected virtual void DrawLabel(ValidationCommandData data) { var reference = data.Target; - var csIcon = EditorGUIUtility.IconContent("cs Script Icon"); + var csIcon = EditorGUIUtility.IconContent(ScriptIconName); 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); if (GUILayout.Button("Show")) { - ValidationExtensions.OpenReference(reference); + ValidationUtility.OpenReference(reference); _currentItem = data; } } diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/DefaultDrawer.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/DefaultDrawer.cs index 0ba3b29..123e56f 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/DefaultDrawer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/DefaultDrawer.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Linq; -using Better.EditorTools.Helpers; +using Better.EditorTools.EditorAddons.Helpers; using UnityEditor; namespace Better.Validation.EditorAddons.WindowModule.CollectionDrawing diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/GroupDictionaryDrawer.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/GroupDictionaryDrawer.cs index 1c12850..168cca7 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/GroupDictionaryDrawer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/GroupDictionaryDrawer.cs @@ -1,15 +1,17 @@ using System.Collections.Generic; using System.Linq; -using Better.EditorTools.Helpers; -using Better.Validation.EditorAddons.Utilities; +using Better.EditorTools.EditorAddons.Helpers; +using Better.Extensions.Runtime; +using Better.Validation.EditorAddons.Utility; using UnityEditor; namespace Better.Validation.EditorAddons.WindowModule.CollectionDrawing { - public abstract class GroupDictionaryDrawer : CollectionDrawer where TDictionary: class, IDictionary>> + public abstract class GroupDictionaryDrawer : CollectionDrawer + where TDictionary : class, IDictionary>>, new() { - protected TDictionary _dataDictionary = null; - protected int _count; + private TDictionary _dataDictionary = null; + private int _count; public override int Count => _count; @@ -23,6 +25,24 @@ public override ValidationCommandData GetPrevious() return GetAtDirection(-1); } + public override CollectionDrawer Initialize(List data) + { + if (data.IsNullOrEmpty()) + { + _dataDictionary = new TDictionary(); + _count = 0; + } + else + { + _dataDictionary = OnInitialize(data); + _count = _dataDictionary.Sum(x => x.Value.Item2.Count); + } + + return this; + } + + protected abstract TDictionary OnInitialize(List data); + protected abstract string FoldoutName(TKey key); public override void DrawCollection() @@ -34,6 +54,7 @@ public override void DrawCollection() { value.Item1 = value.Item2.Contains(_currentItem); } + using (var groupScope = new FoldoutHeaderGroupScope(value.Item1, FoldoutName(keyValue.Key))) { if (groupScope.IsFolded) @@ -72,7 +93,7 @@ private ValidationCommandData GetAtDirection(int direction) return _currentItem; } - + public override void ClearResolved() { foreach (var keyValue in _dataDictionary.Values) @@ -98,7 +119,7 @@ public override void Revalidate() } } } - + public override bool IsValid() { return _dataDictionary != null; @@ -106,6 +127,11 @@ public override bool IsValid() protected override List GetRemaining() { + if (!IsValid()) + { + return new List(); + } + return _dataDictionary.Values.SelectMany(x => x.Item2).ToList(); } } diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/ObjectGroupDrawer.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/ObjectGroupDrawer.cs index 1d01f30..3fc57aa 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/ObjectGroupDrawer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/ObjectGroupDrawer.cs @@ -13,22 +13,21 @@ public override string GetOptionName() return "Object Group"; } - public override CollectionDrawer Initialize(List data) + protected override Dictionary>> OnInitialize(List data) { - _dataDictionary = new Dictionary>>(GameObjectGroupingComparer.Instance); + var dataDictionary = new Dictionary>>(GameObjectGroupingComparer.Instance); foreach (var commandData in data) { - if (!_dataDictionary.TryGetValue(commandData.Target, out var list)) + if (!dataDictionary.TryGetValue(commandData.Target, out var list)) { list = new MutableTuple>(true, new List()); - _dataDictionary.Add(commandData.Target, list); + dataDictionary.Add(commandData.Target, list); } list.Item2.Add(commandData); } - _count = _dataDictionary.Sum(x => x.Value.Item2.Count); - return this; + return dataDictionary; } protected override string FoldoutName(Object key) diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/TypeGroupDrawer.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/TypeGroupDrawer.cs index 92e5d33..5ee2d1a 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/TypeGroupDrawer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/CollectionDrawing/TypeGroupDrawer.cs @@ -13,29 +13,25 @@ public override string GetOptionName() return "Type Group"; } - public override CollectionDrawer Initialize(List data) + protected override SortedDictionary>> OnInitialize(List data) { - _dataDictionary = + var dataDictionary = 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)) + if (!dataDictionary.TryGetValue(iconType, out var list)) { - list = new MutableTuple>(iconType == ValidationType.Error || commandData == _currentItem, - new List()); - _dataDictionary.Add(iconType, list); + list = new MutableTuple>(iconType == ValidationType.Error || commandData == _currentItem, new List()); + dataDictionary.Add(iconType, list); } list.Item2.Add(commandData); } - _count = _dataDictionary.Sum(x => x.Value.Item2.Count); - return this; + return dataDictionary; } - public override int Count => _count; - protected override string FoldoutName(ValidationType key) { diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/GameObjectGroupingComparer.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/GameObjectGroupingComparer.cs index cad765e..3fae560 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/GameObjectGroupingComparer.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/GameObjectGroupingComparer.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using Better.EditorTools.Comparers; +using Better.EditorTools.EditorAddons.Comparers; using UnityEngine; namespace Better.Validation.EditorAddons.WindowModule diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/ButtonPage.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/ButtonPage.cs index 415ebcb..b7b5981 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/ButtonPage.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/ButtonPage.cs @@ -1,18 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; -using Better.EditorTools.Helpers; +using Better.EditorTools.EditorAddons.Helpers; using Better.Extensions.Runtime; -using Better.Validation.EditorAddons.Utilities; -using Better.Validation.EditorAddons.WindowModule.Pages.Tab; +using Better.Validation.EditorAddons.Utility; using UnityEditor; using UnityEngine; -namespace Better.Validation.EditorAddons.WindowModule.Pages +namespace Better.Validation.EditorAddons.WindowModule { public class ButtonPage : IWindowPage { - private ValidatorCommands _commands; private int _groupID; private string[] _groupNames; @@ -23,9 +21,9 @@ public class ButtonPage : IWindowPage public void Initialize() { - _commands = new ValidatorCommands(); - _buttons = typeof(IValidationTab).GetAllInheritedType().Select(type => (IValidationTab)Activator.CreateInstance(type)).OrderBy(tab => tab.Order) - .ToArray(); + _buttons = typeof(IValidationTab).GetAllInheritedTypesWithoutUnityObject() + .Select(type => (IValidationTab)Activator.CreateInstance(type)).OrderBy(tab => tab.Order).ToArray(); + foreach (var validationButton in _buttons) { validationButton.Initialize(); @@ -37,12 +35,16 @@ public void Initialize() public IWindowPage DrawUpdate() { + if (_buttons.Length <= 0) return null; List list = null; 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 = _currentTab.DrawUpdate(); diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/IWindowPage.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/IWindowPage.cs index f2d026e..b9879af 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/IWindowPage.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/IWindowPage.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace Better.Validation.EditorAddons.WindowModule.Pages +namespace Better.Validation.EditorAddons.WindowModule { public interface IWindowPage { diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/ResultPage.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/ResultPage.cs index 89392c6..8f087ec 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/ResultPage.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/ResultPage.cs @@ -1,20 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; -using Better.EditorTools.Helpers; +using Better.EditorTools.EditorAddons.Helpers; using Better.Extensions.Runtime; -using Better.Validation.EditorAddons.Utilities; +using Better.Validation.EditorAddons.Utility; using Better.Validation.EditorAddons.WindowModule.CollectionDrawing; using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; using UnityEngine.SceneManagement; -#if !UNITY_2021_1_OR_NEWER -using UnityEditor.Experimental.SceneManagement; -#endif - -namespace Better.Validation.EditorAddons.WindowModule.Pages +namespace Better.Validation.EditorAddons.WindowModule { public class ResultPage : IWindowPage { @@ -42,13 +38,15 @@ public void SetData(List data) public void Initialize() { - _groups = typeof(CollectionDrawer).GetAllInheritedType().Select(x => (CollectionDrawer)Activator.CreateInstance(x)).OrderBy(x => x.Order).ToArray(); + _groups = typeof(CollectionDrawer).GetAllInheritedTypesWithoutUnityObject() + .Select(x => (CollectionDrawer)Activator.CreateInstance(x)).OrderBy(x => x.Order).ToArray(); _groupNames = _groups.Select(x => x.GetOptionName()).ToArray(); } public IWindowPage DrawUpdate() { if (_collectionDrawer == null || !_collectionDrawer.IsValid()) return null; + if (_groups.Length <= 0) return null; using (new EditorGUILayout.VerticalScope()) { if (DrawBackControl(out var backPage)) return backPage; @@ -139,7 +137,7 @@ private void DrawNextButton() var nextObject = _collectionDrawer.GetNext(); - ValidationExtensions.OpenReference(nextObject.Target); + ValidationUtility.OpenReference(nextObject.Target); } private void DrawPrevButton() @@ -148,14 +146,7 @@ private void DrawPrevButton() var nextObject = _collectionDrawer.GetPrevious(); - ValidationExtensions.OpenReference(nextObject.Target); - } - - public void DrawBackButton() - { - var nextObject = _collectionDrawer.GetNext(); - - ValidationExtensions.OpenReference(nextObject.Target); + ValidationUtility.OpenReference(nextObject.Target); } private void DrawClearButton() diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/BaseValidationTab.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/BaseValidationTab.cs index 55ff100..4a08fa4 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/BaseValidationTab.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/BaseValidationTab.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Better.Validation.EditorAddons.WindowModule.Pages.Tab +namespace Better.Validation.EditorAddons.WindowModule { public abstract class BaseValidationTab : IValidationTab { diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/IValidationTab.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/IValidationTab.cs index aa7176f..3c20b1c 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/IValidationTab.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/IValidationTab.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Better.Validation.EditorAddons.WindowModule.Pages.Tab +namespace Better.Validation.EditorAddons.WindowModule { public interface IValidationTab { diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/MissingReferenceTab.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/MissingReferenceTab.cs index 7c8be97..8b7f71d 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/MissingReferenceTab.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/MissingReferenceTab.cs @@ -2,7 +2,7 @@ using UnityEditor; using UnityEngine; -namespace Better.Validation.EditorAddons.WindowModule.Pages.Tab +namespace Better.Validation.EditorAddons.WindowModule { public class MissingReferenceTab : BaseValidationTab { diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/ValidateTab.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/ValidateTab.cs index bdae266..7190255 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/ValidateTab.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/Pages/Tab/ValidateTab.cs @@ -2,7 +2,7 @@ using UnityEditor; using UnityEngine; -namespace Better.Validation.EditorAddons.WindowModule.Pages.Tab +namespace Better.Validation.EditorAddons.WindowModule { public class ValidateTab : BaseValidationTab { diff --git a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/ValidationWindow.cs b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/ValidationWindow.cs index 59aad52..23bd4fb 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/WindowModule/ValidationWindow.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/WindowModule/ValidationWindow.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using Better.Extensions.Runtime; -using Better.Validation.EditorAddons.WindowModule.Pages; using UnityEditor; using UnityEngine; diff --git a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/DataValidationWrapper.cs b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/DataValidationWrapper.cs index c71fed7..bcfb4a1 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/DataValidationWrapper.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/DataValidationWrapper.cs @@ -1,22 +1,22 @@ using System.Reflection; -using Better.EditorTools; -using Better.EditorTools.Helpers; -using Better.EditorTools.Helpers.Caching; +using Better.EditorTools.EditorAddons.Helpers; +using Better.EditorTools.EditorAddons.Helpers.Caching; +using Better.Extensions.EditorAddons; using Better.Extensions.Runtime; -using Better.Tools.Runtime; +using Better.Internal.Core.Runtime; using Better.Validation.Runtime.Attributes; namespace Better.Validation.EditorAddons.Wrappers { public class DataValidationWrapper : PropertyValidationWrapper { - public override Cache Validate() + public override CacheValue Validate() { var fieldCache = Property.GetFieldInfoAndStaticTypeFromProperty(); var att = (DataValidationAttribute)Attribute; var propertyContainer = Property.GetPropertyContainer(); - var method = propertyContainer.GetType().GetMethod(att.MethodName, BetterEditorDefines.MethodFlags); + var method = propertyContainer.GetType().GetMethod(att.MethodName, Defines.MethodFlags); var methodName = DrawersHelper.BeautifyFormat(att.MethodName); if (method == null) { @@ -44,7 +44,7 @@ public override Cache Validate() return InvokeMethod(method, fieldCache, propertyContainer); } - private Cache InvokeMethod(MethodInfo method, FieldInfoCache fieldCache, object propertyContainer) + private CacheValue InvokeMethod(MethodInfo method, CachedFieldInfo fieldCache, object propertyContainer) { var value = Property.GetValue(); var parameters = new object[] { value }; @@ -57,7 +57,7 @@ private Cache InvokeMethod(MethodInfo method, FieldInfoCache fieldCache, var result = (bool)method.Invoke(propertyContainer, parameters); if (!result) { - var name = fieldCache.FieldInfo.IsArrayOrList() ? Property.GetArrayPath() : propertyContainer.GetType().Name; + var name = fieldCache.FieldInfo.FieldType.IsArrayOrList() ? Property.GetArrayPath() : propertyContainer.GetType().Name; return GetNotValidCache( $"Validation failed of {DrawersHelper.BeautifyFormat(fieldCache.FieldInfo.Name)} in {DrawersHelper.BeautifyFormat(name)}"); } diff --git a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/MissingComponentWrapper.cs b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/MissingComponentWrapper.cs index 31a5f6f..8d82c91 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/MissingComponentWrapper.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/MissingComponentWrapper.cs @@ -1,4 +1,4 @@ -using Better.EditorTools.Helpers.Caching; +using Better.EditorTools.EditorAddons.Helpers.Caching; using Better.Validation.Runtime.Attributes; using UnityEngine; @@ -15,7 +15,7 @@ public MissingComponentWrapper(Object target) public override ValidationType Type => ValidationType.Error; - public override Cache Validate() + public override CacheValue Validate() { if (!_target) return GetClearCache(); if (_target is GameObject gameObject) diff --git a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/MissingReferenceWrapper.cs b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/MissingReferenceWrapper.cs new file mode 100644 index 0000000..86cd7fc --- /dev/null +++ b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/MissingReferenceWrapper.cs @@ -0,0 +1,29 @@ +using Better.EditorTools.EditorAddons.Helpers; +using Better.EditorTools.EditorAddons.Helpers.Caching; +using Better.Extensions.Runtime; +using UnityEditor; + +namespace Better.Validation.EditorAddons.Wrappers +{ + public class MissingReferenceWrapper : PropertyValidationWrapper + { + public override CacheValue Validate() + { + if (Property.objectReferenceValue.IsNullOrDestroyed()) + { + var fieldName = DrawersHelper.BeautifyFormat(Property.displayName); + if (Property.objectReferenceInstanceIDValue != 0) + { + return GetNotValidCache($"Object in {fieldName} field is missing reference"); + } + } + + return GetClearCache(); + } + + public override bool IsSupported() + { + return Property.propertyType == SerializedPropertyType.ObjectReference; + } + } +} \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/MissingReferenceWrapper.cs.meta b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/MissingReferenceWrapper.cs.meta new file mode 100644 index 0000000..c159f96 --- /dev/null +++ b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/MissingReferenceWrapper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 89eae67d70764380b15302e44e1b0220 +timeCreated: 1709471256 \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/NotNullWrapper.cs b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/NotNullWrapper.cs index 8ab4894..0963a9c 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/NotNullWrapper.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/NotNullWrapper.cs @@ -1,5 +1,5 @@ -using Better.EditorTools.Helpers; -using Better.EditorTools.Helpers.Caching; +using Better.EditorTools.EditorAddons.Helpers; +using Better.EditorTools.EditorAddons.Helpers.Caching; using Better.Extensions.Runtime; using UnityEditor; @@ -7,7 +7,7 @@ namespace Better.Validation.EditorAddons.Wrappers { public class NotNullWrapper : PropertyValidationWrapper { - public override Cache Validate() + public override CacheValue Validate() { if (Property.objectReferenceValue.IsNullOrDestroyed()) { @@ -28,26 +28,4 @@ public override bool IsSupported() return Property.propertyType == SerializedPropertyType.ObjectReference; } } - - public class MissingReferenceWrapper : PropertyValidationWrapper - { - public override Cache Validate() - { - if (Property.objectReferenceValue.IsNullOrDestroyed()) - { - var fieldName = DrawersHelper.BeautifyFormat(Property.displayName); - if (Property.objectReferenceInstanceIDValue != 0) - { - return GetNotValidCache($"Object in {fieldName} field is missing reference"); - } - } - - return GetClearCache(); - } - - public override bool IsSupported() - { - return Property.propertyType == SerializedPropertyType.ObjectReference; - } - } } \ No newline at end of file diff --git a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/PrefabWrapper.cs b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/PrefabWrapper.cs index 876916d..8c993b5 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/PrefabWrapper.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/PrefabWrapper.cs @@ -1,12 +1,12 @@ -using Better.EditorTools.Helpers; -using Better.EditorTools.Helpers.Caching; +using Better.EditorTools.EditorAddons.Helpers; +using Better.EditorTools.EditorAddons.Helpers.Caching; using UnityEditor; namespace Better.Validation.EditorAddons.Wrappers { public class PrefabWrapper : NotNullWrapper { - public override Cache Validate() + public override CacheValue Validate() { var baseResult = base.Validate(); if (!baseResult.IsValid) diff --git a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/RequireComponentWrapper.cs b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/RequireComponentWrapper.cs index 15329d6..f570503 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/RequireComponentWrapper.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/RequireComponentWrapper.cs @@ -1,6 +1,6 @@ using System; -using Better.EditorTools.Helpers; -using Better.EditorTools.Helpers.Caching; +using Better.EditorTools.EditorAddons.Helpers; +using Better.EditorTools.EditorAddons.Helpers.Caching; using Better.Validation.Runtime.Attributes; using UnityEditor; using UnityEngine; @@ -17,7 +17,7 @@ public override void SetProperty(SerializedProperty property, ValidationAttribut _attributeData = (FindAttribute)attribute; } - public override Cache Validate() + public override CacheValue Validate() { var obj = Property.objectReferenceValue; if (_attributeData.ValidateIfFieldEmpty) @@ -32,6 +32,7 @@ public override Cache Validate() var targetObject = propertySerializedObject.targetObject; var gameObject = ((Component)targetObject)?.gameObject; if (gameObject) + { switch (_attributeData.RequireDirection) { case RequireDirection.Parent: @@ -46,6 +47,7 @@ public override Cache Validate() default: throw new ArgumentOutOfRangeException(); } + } if (!obj) { diff --git a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/SceneReferenceWrapper.cs b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/SceneReferenceWrapper.cs index c9bbf57..2687a93 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/SceneReferenceWrapper.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/SceneReferenceWrapper.cs @@ -1,5 +1,5 @@ -using Better.EditorTools.Helpers; -using Better.EditorTools.Helpers.Caching; +using Better.EditorTools.EditorAddons.Helpers; +using Better.EditorTools.EditorAddons.Helpers.Caching; using Better.Extensions.Runtime; using UnityEditor; using UnityEngine; @@ -8,7 +8,7 @@ namespace Better.Validation.EditorAddons.Wrappers { public class SceneReferenceWrapper : NotNullWrapper { - public override Cache Validate() + public override CacheValue Validate() { var baseResult = base.Validate(); if (!baseResult.IsValid) @@ -23,7 +23,7 @@ public override Cache Validate() return ValidateNotPrefabContext(obj, target); } - private Cache ValidateNotPrefabContext(Object obj, Object target) + private CacheValue ValidateNotPrefabContext(Object obj, Object target) { var isObjectInScene = IsObjectInScene(obj); var isTargetInScene = IsObjectInScene(target); @@ -57,7 +57,7 @@ private bool IsObjectInScene(Object obj) return false; } - private Cache ValueTuple(Object obj, Object target) + private CacheValue ValueTuple(Object obj, Object target) { var objRoot = GetOutermostPrefabInstanceRoot(obj); var targetRoot = GetOutermostPrefabInstanceRoot(target); diff --git a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/ValidationWrapper.cs b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/ValidationWrapper.cs index aa8f0ab..1e5795b 100644 --- a/Assets/BetterValidation/Editor/EditorAddons/Wrappers/ValidationWrapper.cs +++ b/Assets/BetterValidation/Editor/EditorAddons/Wrappers/ValidationWrapper.cs @@ -1,26 +1,26 @@ -using Better.EditorTools.Helpers.Caching; -using Better.EditorTools.Utilities; +using Better.EditorTools.EditorAddons.Helpers.Caching; +using Better.EditorTools.EditorAddons.Utilities; using Better.Validation.Runtime.Attributes; namespace Better.Validation.EditorAddons.Wrappers { public abstract class ValidationWrapper : UtilityWrapper { - internal static readonly Cache CacheField = new Cache(); + internal static readonly CacheValue CacheField = new CacheValue(); public abstract ValidationType Type { get; } - public abstract Cache Validate(); + public abstract CacheValue Validate(); public abstract bool IsSupported(); - public static Cache GetNotValidCache(string value) + public static CacheValue GetNotValidCache(string value) { CacheField.Set(false, value); return CacheField; } - public static Cache GetClearCache() + public static CacheValue GetClearCache() { CacheField.Set(true, string.Empty); return CacheField; diff --git a/Assets/BetterValidation/Runtime/Attributes/DataValidationAttribute.cs b/Assets/BetterValidation/Runtime/Attributes/DataValidationAttribute.cs index 4cfedb8..c5571f2 100644 --- a/Assets/BetterValidation/Runtime/Attributes/DataValidationAttribute.cs +++ b/Assets/BetterValidation/Runtime/Attributes/DataValidationAttribute.cs @@ -1,10 +1,10 @@ using System; using System.Diagnostics; -using Better.Tools.Runtime; +using Better.Internal.Core.Runtime; namespace Better.Validation.Runtime.Attributes { - [Conditional(BetterEditorDefines.Editor)] + [Conditional(Defines.Editor)] [AttributeUsage(AttributeTargets.Field)] public class DataValidationAttribute : ValidationAttribute { diff --git a/Assets/BetterValidation/Runtime/Attributes/FindAttribute.cs b/Assets/BetterValidation/Runtime/Attributes/FindAttribute.cs index 19efed3..044b314 100644 --- a/Assets/BetterValidation/Runtime/Attributes/FindAttribute.cs +++ b/Assets/BetterValidation/Runtime/Attributes/FindAttribute.cs @@ -1,6 +1,6 @@ using System; using System.Diagnostics; -using Better.Tools.Runtime; +using Better.Internal.Core.Runtime; namespace Better.Validation.Runtime.Attributes { @@ -11,7 +11,7 @@ public enum RequireDirection Child } - [Conditional(BetterEditorDefines.Editor)] + [Conditional(Defines.Editor)] [AttributeUsage(AttributeTargets.Field)] public class FindAttribute : ValidationAttribute { diff --git a/Assets/BetterValidation/Runtime/Attributes/NotNullAttribute.cs b/Assets/BetterValidation/Runtime/Attributes/NotNullAttribute.cs index 301f512..9c0cfc7 100644 --- a/Assets/BetterValidation/Runtime/Attributes/NotNullAttribute.cs +++ b/Assets/BetterValidation/Runtime/Attributes/NotNullAttribute.cs @@ -1,10 +1,10 @@ using System; using System.Diagnostics; -using Better.Tools.Runtime; +using Better.Internal.Core.Runtime; namespace Better.Validation.Runtime.Attributes { - [Conditional(BetterEditorDefines.Editor)] + [Conditional(Defines.Editor)] [AttributeUsage(AttributeTargets.Field)] public class NotNullAttribute : ValidationAttribute { diff --git a/Assets/BetterValidation/Runtime/Attributes/PrefabReferenceAttribute.cs b/Assets/BetterValidation/Runtime/Attributes/PrefabReferenceAttribute.cs index 11e90be..6be8634 100644 --- a/Assets/BetterValidation/Runtime/Attributes/PrefabReferenceAttribute.cs +++ b/Assets/BetterValidation/Runtime/Attributes/PrefabReferenceAttribute.cs @@ -1,10 +1,10 @@ using System; using System.Diagnostics; -using Better.Tools.Runtime; +using Better.Internal.Core.Runtime; namespace Better.Validation.Runtime.Attributes { - [Conditional(BetterEditorDefines.Editor)] + [Conditional(Defines.Editor)] [AttributeUsage(AttributeTargets.Field)] public class PrefabReferenceAttribute : ValidationAttribute { diff --git a/Assets/BetterValidation/Runtime/Attributes/SceneReferenceAttribute.cs b/Assets/BetterValidation/Runtime/Attributes/SceneReferenceAttribute.cs index 40a54ba..8146aea 100644 --- a/Assets/BetterValidation/Runtime/Attributes/SceneReferenceAttribute.cs +++ b/Assets/BetterValidation/Runtime/Attributes/SceneReferenceAttribute.cs @@ -1,10 +1,10 @@ using System; using System.Diagnostics; -using Better.Tools.Runtime; +using Better.Internal.Core.Runtime; namespace Better.Validation.Runtime.Attributes { - [Conditional(BetterEditorDefines.Editor)] + [Conditional(Defines.Editor)] [AttributeUsage(AttributeTargets.Field)] public class SceneReferenceAttribute : ValidationAttribute { diff --git a/Assets/BetterValidation/Runtime/Attributes/ValidationAttribute.cs b/Assets/BetterValidation/Runtime/Attributes/ValidationAttribute.cs index 3e20a70..fc8e342 100644 --- a/Assets/BetterValidation/Runtime/Attributes/ValidationAttribute.cs +++ b/Assets/BetterValidation/Runtime/Attributes/ValidationAttribute.cs @@ -1,8 +1,7 @@ using System; using System.Diagnostics; -using Better.Tools.Runtime; -using Better.Tools.Runtime.Attributes; -using UnityEngine; +using Better.EditorTools.Runtime.Attributes; +using Better.Internal.Core.Runtime; namespace Better.Validation.Runtime.Attributes { @@ -13,7 +12,7 @@ public enum ValidationType Error = 2 } - [Conditional(BetterEditorDefines.Editor)] + [Conditional(Defines.Editor)] [AttributeUsage(AttributeTargets.Field)] public abstract class ValidationAttribute : MultiPropertyAttribute { diff --git a/Assets/BetterValidation/Runtime/BetterValidation.Runtime.asmdef b/Assets/BetterValidation/Runtime/BetterValidation.Runtime.asmdef index fe1a4e5..bda634e 100644 --- a/Assets/BetterValidation/Runtime/BetterValidation.Runtime.asmdef +++ b/Assets/BetterValidation/Runtime/BetterValidation.Runtime.asmdef @@ -1,8 +1,9 @@ { - "name": "Better", + "name": "BetterValidation.Runtime", "rootNamespace": "Better.Validation.Runtime", "references": [ - "GUID:a59e3daedde9ca94bba45364d4ead25f" + "GUID:a59e3daedde9ca94bba45364d4ead25f", + "GUID:01df13aca8d01e24a911bcc3e8277031" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Assets/BetterValidation/Samples~/TestSamples/Editor/TestValidationPage.cs b/Assets/BetterValidation/Samples~/TestSamples/Editor/TestValidationPage.cs index 688a6b0..f7805ff 100644 --- a/Assets/BetterValidation/Samples~/TestSamples/Editor/TestValidationPage.cs +++ b/Assets/BetterValidation/Samples~/TestSamples/Editor/TestValidationPage.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using Better.Validation.EditorAddons; -using Better.Validation.EditorAddons.WindowModule.Pages.Tab; +using Better.Validation.EditorAddons.WindowModule; using UnityEditor; using UnityEngine; diff --git a/Assets/BetterValidation/Samples~/TestSamples/Editor/TestValidationStep.cs b/Assets/BetterValidation/Samples~/TestSamples/Editor/TestValidationStep.cs index 0c72280..eca93b4 100644 --- a/Assets/BetterValidation/Samples~/TestSamples/Editor/TestValidationStep.cs +++ b/Assets/BetterValidation/Samples~/TestSamples/Editor/TestValidationStep.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using Better.Validation.EditorAddons; -using Better.Validation.EditorAddons.PreBuildValidation.Interfaces; +using Better.Validation.EditorAddons.PreBuildValidation; using UnityEngine; namespace BetterValidation.Samples.TestSamples.Editor @@ -11,7 +11,7 @@ public class TestValidationStep : IBuildValidationStep { [SerializeField] private string customText = "You can add your custom validation step"; - public List GatherValidationData() + public List GatherValidationData(ValidatorCommands commands) { return new List(); } diff --git a/Assets/BetterValidation/package.json b/Assets/BetterValidation/package.json index cdb29ff..75a5039 100644 --- a/Assets/BetterValidation/package.json +++ b/Assets/BetterValidation/package.json @@ -1,11 +1,14 @@ { "name": "com.uurha.bettervalidation", "displayName": "Better Validation", - "version": "1.0.61", - "unity": "2020.1", + "version": "1.5.0", + "unity": "2021.3", "description": " ", "dependencies": { - "com.uurha.bettereditortools": "1.0.69" + "com.uurha.bettereditortools": "1.5.22", + "com.tdw.better.internal.core": "0.0.2", + "com.tdw.better.projectsettings": "0.0.1", + "com.tdw.better.singletons" : "0.0.7" }, "author": { "name": "Better Plugins", diff --git a/BetterValidation.Editor.csproj.DotSettings b/BetterValidation.Editor.csproj.DotSettings new file mode 100644 index 0000000..5f5f683 --- /dev/null +++ b/BetterValidation.Editor.csproj.DotSettings @@ -0,0 +1,8 @@ + + True + True + True + True + True + True + True \ No newline at end of file diff --git a/BetterValidation.Runtime.csproj.DotSettings b/BetterValidation.Runtime.csproj.DotSettings new file mode 100644 index 0000000..d4d43b7 --- /dev/null +++ b/BetterValidation.Runtime.csproj.DotSettings @@ -0,0 +1,3 @@ + + True + True \ No newline at end of file diff --git a/Packages/manifest.json b/Packages/manifest.json index 8852ae6..57d6662 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -1,18 +1,20 @@ { "dependencies": { - "com.unity.collab-proxy": "1.17.7", + "com.tdw.better.internal.core": "0.0.2", + "com.tdw.better.projectsettings": "0.0.1", + "com.unity.collab-proxy": "2.0.1", "com.unity.feature.development": "1.0.1", - "com.unity.ide.rider": "3.0.16", - "com.unity.ide.visualstudio": "2.0.16", + "com.unity.ide.rider": "3.0.18", + "com.unity.ide.visualstudio": "2.0.17", "com.unity.ide.vscode": "1.2.5", "com.unity.memoryprofiler": "0.7.1-preview.1", "com.unity.test-framework": "1.1.31", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.6.4", "com.unity.ugui": "1.0.0", - "com.unity.visualscripting": "1.7.8", + "com.unity.visualscripting": "1.8.0", "com.uurha.betterdatastructures": "0.0.4", - "com.uurha.bettereditortools": "1.0.69", + "com.uurha.bettereditortools": "1.5.23", "com.uurha.betterextensions": "1.1.91", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", @@ -51,7 +53,8 @@ "name": "Arcueid Plugins", "url": "https://package.openupm.com", "scopes": [ - "com.uurha" + "com.uurha", + "com.tdw" ] } ] diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 74ef058..5b627fe 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -1,12 +1,38 @@ { "dependencies": { - "com.unity.collab-proxy": { - "version": "1.17.7", + "com.tdw.better.internal.core": { + "version": "0.0.2", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://package.openupm.com" + }, + "com.tdw.better.projectsettings": { + "version": "0.0.1", "depth": 0, "source": "registry", "dependencies": { - "com.unity.services.core": "1.0.1" + "com.tdw.better.singletons": "0.0.7", + "com.uurha.betterextensions": "1.5.3", + "com.tdw.better.internal.core": "0.0.2" }, + "url": "https://package.openupm.com" + }, + "com.tdw.better.singletons": { + "version": "0.0.7", + "depth": 1, + "source": "registry", + "dependencies": { + "com.uurha.betterextensions": "1.5.2", + "com.tdw.better.internal.core": "0.0.2" + }, + "url": "https://package.openupm.com" + }, + "com.unity.collab-proxy": { + "version": "2.0.1", + "depth": 0, + "source": "registry", + "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.editorcoroutines": { @@ -28,17 +54,17 @@ "depth": 0, "source": "builtin", "dependencies": { - "com.unity.ide.visualstudio": "2.0.16", - "com.unity.ide.rider": "3.0.16", + "com.unity.ide.visualstudio": "2.0.17", + "com.unity.ide.rider": "3.0.18", "com.unity.ide.vscode": "1.2.5", "com.unity.editorcoroutines": "1.0.0", - "com.unity.performance.profile-analyzer": "1.1.1", + "com.unity.performance.profile-analyzer": "1.2.2", "com.unity.test-framework": "1.1.31", "com.unity.testtools.codecoverage": "1.2.2" } }, "com.unity.ide.rider": { - "version": "3.0.16", + "version": "3.0.18", "depth": 0, "source": "registry", "dependencies": { @@ -47,7 +73,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.16", + "version": "2.0.17", "depth": 0, "source": "registry", "dependencies": { @@ -71,31 +97,13 @@ }, "url": "https://packages.unity.com" }, - "com.unity.nuget.newtonsoft-json": { - "version": "3.0.2", - "depth": 2, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, "com.unity.performance.profile-analyzer": { - "version": "1.1.1", + "version": "1.2.2", "depth": 1, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, - "com.unity.services.core": { - "version": "1.6.0", - "depth": 1, - "source": "registry", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.nuget.newtonsoft-json": "3.0.2", - "com.unity.modules.androidjni": "1.0.0" - }, - "url": "https://packages.unity.com" - }, "com.unity.settings-manager": { "version": "1.0.3", "depth": 2, @@ -155,7 +163,7 @@ } }, "com.unity.visualscripting": { - "version": "1.7.8", + "version": "1.8.0", "depth": 0, "source": "registry", "dependencies": { @@ -165,27 +173,32 @@ "url": "https://packages.unity.com" }, "com.uurha.betterdatastructures": { - "version": "0.1.2", + "version": "0.1.7", "depth": 1, "source": "registry", - "dependencies": {}, + "dependencies": { + "com.tdw.better.internal.core": "0.0.2" + }, "url": "https://package.openupm.com" }, "com.uurha.bettereditortools": { - "version": "1.0.69", + "version": "1.5.23", "depth": 0, "source": "registry", "dependencies": { - "com.uurha.betterdatastructures": "0.1.2", - "com.uurha.betterextensions": "1.1.98" + "com.uurha.betterdatastructures": "0.1.7", + "com.uurha.betterextensions": "1.5.94", + "com.tdw.better.internal.core": "0.0.2" }, "url": "https://package.openupm.com" }, "com.uurha.betterextensions": { - "version": "1.1.98", + "version": "1.5.94", "depth": 1, "source": "registry", - "dependencies": {}, + "dependencies": { + "com.tdw.better.internal.core": "0.0.2" + }, "url": "https://package.openupm.com" }, "com.unity.modules.ai": { diff --git a/ProjectSettings/PackageManagerSettings.asset b/ProjectSettings/PackageManagerSettings.asset index 739e538..c05d6bd 100644 --- a/ProjectSettings/PackageManagerSettings.asset +++ b/ProjectSettings/PackageManagerSettings.asset @@ -31,6 +31,7 @@ MonoBehaviour: m_Url: https://package.openupm.com m_Scopes: - com.uurha + - com.tdw m_IsDefault: 0 m_Capabilities: 0 m_ConfigSource: 4 @@ -39,6 +40,6 @@ MonoBehaviour: m_RegistryInfoDraft: m_Modified: 0 m_ErrorMessage: - m_UserModificationsInstanceId: -850 - m_OriginalInstanceId: -852 + m_UserModificationsInstanceId: -830 + m_OriginalInstanceId: -834 m_LoadAssets: 0 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 3643b02..bca3d02 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2021.3.16f1 -m_EditorVersionWithRevision: 2021.3.16f1 (4016570cf34f) +m_EditorVersion: 2021.3.21f1 +m_EditorVersionWithRevision: 2021.3.21f1 (1b156197d683)