Compare commits
No commits in common. "main" and "0.5.0" have entirely different histories.
33 changed files with 56 additions and 948 deletions
|
|
@ -10,31 +10,18 @@ namespace Module.ProjectValidator.Editor
|
||||||
{
|
{
|
||||||
static EditorProjectValidatorHierarchy()
|
static EditorProjectValidatorHierarchy()
|
||||||
{
|
{
|
||||||
#if UNITY_6000_4_OR_NEWER
|
|
||||||
EditorApplication.hierarchyWindowItemByEntityIdOnGUI -= OnHierarchyWindowItemByEntityIdOnGUI;
|
|
||||||
EditorApplication.hierarchyWindowItemByEntityIdOnGUI += OnHierarchyWindowItemByEntityIdOnGUI;
|
|
||||||
#else
|
|
||||||
EditorApplication.hierarchyWindowItemOnGUI -= OnHierarchyWindowItemOnGUI;
|
EditorApplication.hierarchyWindowItemOnGUI -= OnHierarchyWindowItemOnGUI;
|
||||||
EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyWindowItemOnGUI;
|
EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyWindowItemOnGUI;
|
||||||
#endif
|
|
||||||
|
|
||||||
EditorSceneManager.sceneOpened -= OnSceneOpened;
|
EditorSceneManager.sceneOpened -= OnSceneOpened;
|
||||||
EditorSceneManager.sceneOpened += OnSceneOpened;
|
EditorSceneManager.sceneOpened += OnSceneOpened;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_6000_4_OR_NEWER
|
|
||||||
private static void OnHierarchyWindowItemByEntityIdOnGUI(EntityId entityId, Rect selectionRect)
|
|
||||||
{
|
|
||||||
if (Report.HasActive && Report.Active.TryGetSeverityFor(entityId, out var instance) && instance.Severity != EValidatorSeverity.Valid)
|
|
||||||
EditorIconUtility.Draw(new Rect(selectionRect.x, selectionRect.y, selectionRect.height, selectionRect.height), instance.Severity, instance.IsRedirect);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
private static void OnHierarchyWindowItemOnGUI(int instanceID, Rect selectionRect)
|
private static void OnHierarchyWindowItemOnGUI(int instanceID, Rect selectionRect)
|
||||||
{
|
{
|
||||||
if (Report.HasActive && Report.Active.TryGetSeverityFor(instanceID, out var instance) && instance.Severity != EValidatorSeverity.Valid)
|
if (Report.HasActive && Report.Active.TryGetSeverityFor(instanceID, out var instance) && instance.Severity != EValidatorSeverity.Valid)
|
||||||
EditorIconUtility.Draw(new Rect(selectionRect.x, selectionRect.y, selectionRect.height, selectionRect.height), instance.Severity, instance.IsRedirect);
|
EditorIconUtility.Draw(new Rect(selectionRect.x, selectionRect.y, selectionRect.height, selectionRect.height), instance.Severity, instance.IsRedirect);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
private static void OnSceneOpened(Scene scene, OpenSceneMode mode)
|
private static void OnSceneOpened(Scene scene, OpenSceneMode mode)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 595 B |
|
|
@ -1,117 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: a6c61d5fbd310894d8159ba6af32d7e3
|
|
||||||
TextureImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 13
|
|
||||||
mipmaps:
|
|
||||||
mipMapMode: 0
|
|
||||||
enableMipMap: 0
|
|
||||||
sRGBTexture: 1
|
|
||||||
linearTexture: 0
|
|
||||||
fadeOut: 0
|
|
||||||
borderMipMap: 0
|
|
||||||
mipMapsPreserveCoverage: 0
|
|
||||||
alphaTestReferenceValue: 0.5
|
|
||||||
mipMapFadeDistanceStart: 1
|
|
||||||
mipMapFadeDistanceEnd: 3
|
|
||||||
bumpmap:
|
|
||||||
convertToNormalMap: 0
|
|
||||||
externalNormalMap: 0
|
|
||||||
heightScale: 0.25
|
|
||||||
normalMapFilter: 0
|
|
||||||
flipGreenChannel: 0
|
|
||||||
isReadable: 0
|
|
||||||
streamingMipmaps: 0
|
|
||||||
streamingMipmapsPriority: 0
|
|
||||||
vTOnly: 0
|
|
||||||
ignoreMipmapLimit: 0
|
|
||||||
grayScaleToAlpha: 0
|
|
||||||
generateCubemap: 6
|
|
||||||
cubemapConvolution: 0
|
|
||||||
seamlessCubemap: 0
|
|
||||||
textureFormat: 1
|
|
||||||
maxTextureSize: 2048
|
|
||||||
textureSettings:
|
|
||||||
serializedVersion: 2
|
|
||||||
filterMode: 1
|
|
||||||
aniso: 1
|
|
||||||
mipBias: 0
|
|
||||||
wrapU: 0
|
|
||||||
wrapV: 0
|
|
||||||
wrapW: 0
|
|
||||||
nPOTScale: 1
|
|
||||||
lightmap: 0
|
|
||||||
compressionQuality: 50
|
|
||||||
spriteMode: 0
|
|
||||||
spriteExtrude: 1
|
|
||||||
spriteMeshType: 1
|
|
||||||
alignment: 0
|
|
||||||
spritePivot: {x: 0.5, y: 0.5}
|
|
||||||
spritePixelsToUnits: 100
|
|
||||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
spriteGenerateFallbackPhysicsShape: 1
|
|
||||||
alphaUsage: 1
|
|
||||||
alphaIsTransparency: 1
|
|
||||||
spriteTessellationDetail: -1
|
|
||||||
textureType: 0
|
|
||||||
textureShape: 1
|
|
||||||
singleChannelComponent: 0
|
|
||||||
flipbookRows: 1
|
|
||||||
flipbookColumns: 1
|
|
||||||
maxTextureSizeSet: 0
|
|
||||||
compressionQualitySet: 0
|
|
||||||
textureFormatSet: 0
|
|
||||||
ignorePngGamma: 0
|
|
||||||
applyGammaDecoding: 0
|
|
||||||
swizzle: 50462976
|
|
||||||
cookieLightType: 0
|
|
||||||
platformSettings:
|
|
||||||
- serializedVersion: 4
|
|
||||||
buildTarget: DefaultTexturePlatform
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
ignorePlatformSupport: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 4
|
|
||||||
buildTarget: Standalone
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
ignorePlatformSupport: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
spriteSheet:
|
|
||||||
serializedVersion: 2
|
|
||||||
sprites: []
|
|
||||||
outline: []
|
|
||||||
customData:
|
|
||||||
physicsShape: []
|
|
||||||
bones: []
|
|
||||||
spriteID:
|
|
||||||
internalID: 0
|
|
||||||
vertices: []
|
|
||||||
indices:
|
|
||||||
edges: []
|
|
||||||
weights: []
|
|
||||||
secondaryTextures: []
|
|
||||||
spriteCustomMetadata:
|
|
||||||
entries: []
|
|
||||||
nameFileIdTable: {}
|
|
||||||
mipmapLimitGroupName:
|
|
||||||
pSDRemoveMatte: 0
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Module.ProjectValidator.Editor
|
namespace Module.ProjectValidator.Editor
|
||||||
{
|
{
|
||||||
|
|
@ -12,12 +11,7 @@ namespace Module.ProjectValidator.Editor
|
||||||
|
|
||||||
public readonly List<Entry> Entries = new();
|
public readonly List<Entry> Entries = new();
|
||||||
private readonly Dictionary<GUID, MappingEntry> _assetToSeverityMapping = new();
|
private readonly Dictionary<GUID, MappingEntry> _assetToSeverityMapping = new();
|
||||||
|
|
||||||
#if UNITY_6000_4_OR_NEWER
|
|
||||||
private readonly Dictionary<EntityId, MappingEntry> _instanceToSeverityMapping = new();
|
|
||||||
#else
|
|
||||||
private readonly Dictionary<int, MappingEntry> _instanceToSeverityMapping = new();
|
private readonly Dictionary<int, MappingEntry> _instanceToSeverityMapping = new();
|
||||||
#endif
|
|
||||||
|
|
||||||
public void Add(GUID assetGuid, string relativePath, string fieldPath, Attribute attribute, EValidatorSeverity severity, string message)
|
public void Add(GUID assetGuid, string relativePath, string fieldPath, Attribute attribute, EValidatorSeverity severity, string message)
|
||||||
{
|
{
|
||||||
|
|
@ -71,16 +65,6 @@ namespace Module.ProjectValidator.Editor
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_6000_4_OR_NEWER
|
|
||||||
public bool TryGetSeverityFor(EntityId entityId, out MappingEntry mapping)
|
|
||||||
{
|
|
||||||
if (_instanceToSeverityMapping.TryGetValue(entityId, out mapping))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
mapping = new MappingEntry();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
public bool TryGetSeverityFor(int instanceId, out MappingEntry mapping)
|
public bool TryGetSeverityFor(int instanceId, out MappingEntry mapping)
|
||||||
{
|
{
|
||||||
if (_instanceToSeverityMapping.TryGetValue(instanceId, out mapping))
|
if (_instanceToSeverityMapping.TryGetValue(instanceId, out mapping))
|
||||||
|
|
@ -89,7 +73,6 @@ namespace Module.ProjectValidator.Editor
|
||||||
mapping = new MappingEntry();
|
mapping = new MappingEntry();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
public bool TryGetSeverityFor(GUID assetGuid, string relativePath, out MappingEntry mapping)
|
public bool TryGetSeverityFor(GUID assetGuid, string relativePath, out MappingEntry mapping)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,16 +31,9 @@ namespace Module.ProjectValidator.Editor
|
||||||
if (!IsFieldSerializable(fi))
|
if (!IsFieldSerializable(fi))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var fieldAttributes = fi.GetCustomAttributes();
|
var attributes = fi.GetCustomAttributes();
|
||||||
var fieldTypeAttributes = fi.FieldType.GetCustomAttributes();
|
|
||||||
|
|
||||||
foreach (var attribute in fieldAttributes)
|
foreach (var attribute in attributes)
|
||||||
{
|
|
||||||
if (validatorList.TryGetAttributeValidator(attribute.GetType(), out var validator))
|
|
||||||
entry.AddField(fi, attribute, validator);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var attribute in fieldTypeAttributes)
|
|
||||||
{
|
{
|
||||||
if (validatorList.TryGetAttributeValidator(attribute.GetType(), out var validator))
|
if (validatorList.TryGetAttributeValidator(attribute.GetType(), out var validator))
|
||||||
entry.AddField(fi, attribute, validator);
|
entry.AddField(fi, attribute, validator);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
@ -12,7 +11,6 @@ namespace Module.ProjectValidator.Editor
|
||||||
private readonly Dictionary<Type, object> _attributeValidators = new();
|
private readonly Dictionary<Type, object> _attributeValidators = new();
|
||||||
private readonly Dictionary<Type, List<object>> _componentValidators = new();
|
private readonly Dictionary<Type, List<object>> _componentValidators = new();
|
||||||
public readonly List<IGameObjectValidator> GameObjectValidators = new();
|
public readonly List<IGameObjectValidator> GameObjectValidators = new();
|
||||||
public readonly Dictionary<Type, List<AssetValidator>> AssetValidators = new();
|
|
||||||
|
|
||||||
public void AddAttribute(Type type)
|
public void AddAttribute(Type type)
|
||||||
{
|
{
|
||||||
|
|
@ -78,33 +76,6 @@ namespace Module.ProjectValidator.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddAsset(Type type)
|
|
||||||
{
|
|
||||||
if (type.IsInterface || type.IsAbstract)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var typeValidator = type.GetInterfaces().FirstOrDefault(typeInterface => typeInterface.IsGenericType && typeInterface.GetGenericTypeDefinition() == typeof(IAssetValidator<>));
|
|
||||||
var componentType = typeValidator?.GetGenericArguments()[0];
|
|
||||||
|
|
||||||
if (componentType == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var instance = FormatterServices.GetUninitializedObject(type);
|
|
||||||
var validator = new AssetValidator(instance);
|
|
||||||
|
|
||||||
if (AssetValidators.TryGetValue(componentType, out var list))
|
|
||||||
list.Add(validator);
|
|
||||||
else
|
|
||||||
AssetValidators.Add(componentType, new List<AssetValidator> { validator });
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TryGetAttributeValidator(Type type, out object validatorInstance)
|
public bool TryGetAttributeValidator(Type type, out object validatorInstance)
|
||||||
{
|
{
|
||||||
return _attributeValidators.TryGetValue(type, out validatorInstance);
|
return _attributeValidators.TryGetValue(type, out validatorInstance);
|
||||||
|
|
@ -114,17 +85,5 @@ namespace Module.ProjectValidator.Editor
|
||||||
{
|
{
|
||||||
return _componentValidators.TryGetValue(type, out validatorInstances);
|
return _componentValidators.TryGetValue(type, out validatorInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class AssetValidator
|
|
||||||
{
|
|
||||||
public readonly object Validator;
|
|
||||||
public readonly MethodInfo ValidatorMethod;
|
|
||||||
|
|
||||||
public AssetValidator(object validator)
|
|
||||||
{
|
|
||||||
Validator = validator;
|
|
||||||
ValidatorMethod = validator.GetType().GetMethod("Validate");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,36 +1,27 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UIElements;
|
using UnityEngine.UIElements;
|
||||||
using UnityEditor.UIElements;
|
using UnityEditor.UIElements;
|
||||||
using UnityEditorInternal;
|
using UnityEditorInternal;
|
||||||
using UnityEngine.Pool;
|
|
||||||
using Object = UnityEngine.Object;
|
|
||||||
|
|
||||||
namespace Module.ProjectValidator.Editor
|
namespace Module.ProjectValidator.Editor
|
||||||
{
|
{
|
||||||
internal sealed class ProjectValidatorSettings : ScriptableObject
|
internal sealed class ProjectValidatorSettings : ScriptableObject
|
||||||
{
|
{
|
||||||
public List<string> assemblies = new();
|
public List<string> assemblies = new();
|
||||||
[NonReorderable]
|
|
||||||
public List<ValidatorEnabled> validators = new();
|
|
||||||
|
|
||||||
public const string MenuPath = "Project/Project Validator";
|
|
||||||
private const string AssetPath = "ProjectSettings/ProjectValidatorSettings.asset";
|
private const string AssetPath = "ProjectSettings/ProjectValidatorSettings.asset";
|
||||||
private const string StyleSheetName = "StyleSheetProjectValidatorSettings";
|
private const string StyleSheetName = "StyleSheetProjectValidatorSettings";
|
||||||
|
|
||||||
internal static ProjectValidatorSettings GetOrCreate()
|
internal static ProjectValidatorSettings GetOrCreate()
|
||||||
{
|
{
|
||||||
var objects = InternalEditorUtility.LoadSerializedFileAndForget(AssetPath);
|
var objects = InternalEditorUtility.LoadSerializedFileAndForget(AssetPath);
|
||||||
ProjectValidatorSettings settings;
|
|
||||||
|
|
||||||
if (objects.Length != 0)
|
if (objects.Length != 0)
|
||||||
settings = (ProjectValidatorSettings)objects[0];
|
return (ProjectValidatorSettings)objects[0];
|
||||||
else
|
|
||||||
settings = CreateInstance<ProjectValidatorSettings>();
|
|
||||||
|
|
||||||
PopulateValidatorList(settings);
|
var settings = CreateInstance<ProjectValidatorSettings>();
|
||||||
InternalEditorUtility.SaveToSerializedFileAndForget(new Object[] { settings }, AssetPath, true);
|
InternalEditorUtility.SaveToSerializedFileAndForget(new Object[] { settings }, AssetPath, true);
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +29,7 @@ namespace Module.ProjectValidator.Editor
|
||||||
[SettingsProvider]
|
[SettingsProvider]
|
||||||
public static SettingsProvider CreateProvider()
|
public static SettingsProvider CreateProvider()
|
||||||
{
|
{
|
||||||
return new SettingsProvider(MenuPath, SettingsScope.Project)
|
return new SettingsProvider("Project/Project Validator", SettingsScope.Project)
|
||||||
{
|
{
|
||||||
label = "Project Validator",
|
label = "Project Validator",
|
||||||
activateHandler = (_, root) =>
|
activateHandler = (_, root) =>
|
||||||
|
|
@ -46,79 +37,16 @@ namespace Module.ProjectValidator.Editor
|
||||||
var settings = GetOrCreate();
|
var settings = GetOrCreate();
|
||||||
var serializedObject = new SerializedObject(settings);
|
var serializedObject = new SerializedObject(settings);
|
||||||
var container = new VisualElement { style = { flexDirection = FlexDirection.Column } };
|
var container = new VisualElement { style = { flexDirection = FlexDirection.Column } };
|
||||||
|
var propertyField = new PropertyField(serializedObject.FindProperty("assemblies"), "Assemblies");
|
||||||
var assemblyField = new PropertyField(serializedObject.FindProperty(nameof(assemblies)), "Assemblies");
|
propertyField.RegisterCallback<ChangeEvent<string>>(_ => InternalEditorUtility.SaveToSerializedFileAndForget(new[] { serializedObject.targetObject }, AssetPath, true));
|
||||||
container.Add(assemblyField);
|
propertyField.RegisterValueChangeCallback(_ => InternalEditorUtility.SaveToSerializedFileAndForget(new[] { serializedObject.targetObject }, AssetPath, true));
|
||||||
|
container.Add(propertyField);
|
||||||
var enabledField = new PropertyField(serializedObject.FindProperty(nameof(validators)), "Validators");
|
|
||||||
container.Add(enabledField);
|
|
||||||
|
|
||||||
root.Add(container);
|
root.Add(container);
|
||||||
root.Bind(serializedObject);
|
root.Bind(serializedObject);
|
||||||
root.RegisterCallback<SerializedObjectChangeEvent>(_ => InternalEditorUtility.SaveToSerializedFileAndForget(new[] { serializedObject.targetObject }, AssetPath, true));
|
|
||||||
root.RegisterCallback<SerializedPropertyChangeEvent>(_ => InternalEditorUtility.SaveToSerializedFileAndForget(new[] { serializedObject.targetObject }, AssetPath, true));
|
|
||||||
root.styleSheets.Add(EditorAssetUtility.LoadFirstAsset<StyleSheet>(StyleSheetName));
|
root.styleSheets.Add(EditorAssetUtility.LoadFirstAsset<StyleSheet>(StyleSheetName));
|
||||||
},
|
},
|
||||||
keywords = new HashSet<string>(new[] { "Project", "Validator", "Assemblies" })
|
keywords = new HashSet<string>(new[] { "Project", "Validator", "Assemblies" })
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PopulateValidatorList(ProjectValidatorSettings settings)
|
|
||||||
{
|
|
||||||
using var pool0 = ListPool<string>.Get(out var list);
|
|
||||||
using var pool1 = ListPool<string>.Get(out var temp);
|
|
||||||
|
|
||||||
FetchValidatorsOfType(typeof(IAssetValidator<>), list);
|
|
||||||
FetchValidatorsOfType(typeof(IAttributeValidator<>), list);
|
|
||||||
FetchValidatorsOfType(typeof(IComponentValidator<>), list);
|
|
||||||
FetchValidatorsOfType(typeof(IGameObjectValidator), list);
|
|
||||||
|
|
||||||
for (var i = 0; i < settings.validators.Count; i++)
|
|
||||||
{
|
|
||||||
temp.Add(settings.validators[i].assemblyQualifiedName);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < list.Count; i++)
|
|
||||||
{
|
|
||||||
if (temp.Contains(list[i]))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var type = Type.GetType(list[i]);
|
|
||||||
var name = type != null ? type.Name : "Unknown Type";
|
|
||||||
settings.validators.Add(new ValidatorEnabled(name, list[i], true));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = temp.Count - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
if (!list.Contains(temp[i]))
|
|
||||||
settings.validators.RemoveAt(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void FetchValidatorsOfType(Type type, List<string> typeNames)
|
|
||||||
{
|
|
||||||
var types = TypeCache.GetTypesDerivedFrom(type);
|
|
||||||
|
|
||||||
for (var i = 0; i < types.Count; i++)
|
|
||||||
{
|
|
||||||
if (!types[i].IsInterface && !types[i].IsAbstract)
|
|
||||||
typeNames.Add(types[i].AssemblyQualifiedName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public sealed class ValidatorEnabled
|
|
||||||
{
|
|
||||||
public string name;
|
|
||||||
public string assemblyQualifiedName;
|
|
||||||
public bool enabled;
|
|
||||||
|
|
||||||
public ValidatorEnabled(string name, string assemblyQualifiedName, bool enabled)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
this.assemblyQualifiedName = assemblyQualifiedName;
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Object = UnityEngine.Object;
|
|
||||||
|
|
||||||
namespace Module.ProjectValidator.Editor
|
namespace Module.ProjectValidator.Editor
|
||||||
{
|
{
|
||||||
|
|
@ -31,22 +29,6 @@ namespace Module.ProjectValidator.Editor
|
||||||
return list.ToArray();
|
return list.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object[] LoadAllAssets(Type type)
|
|
||||||
{
|
|
||||||
var guids = AssetDatabase.FindAssetGUIDs($"a:assets t:{type.Name}");
|
|
||||||
var list = new List<Object>(guids.Length);
|
|
||||||
|
|
||||||
foreach (var guid in guids)
|
|
||||||
{
|
|
||||||
var asset = AssetDatabase.LoadAssetByGUID(guid, type);
|
|
||||||
|
|
||||||
if (asset != null)
|
|
||||||
list.Add(asset);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static GUID GetAssetGuid(Object obj)
|
internal static GUID GetAssetGuid(Object obj)
|
||||||
{
|
{
|
||||||
var assetPath = string.Empty;
|
var assetPath = string.Empty;
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,6 @@ namespace Module.ProjectValidator.Editor
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetAssetValidatorName(object validator)
|
|
||||||
{
|
|
||||||
var str = validator.GetType().Name;
|
|
||||||
str = str.Replace("AssetValidator", string.Empty);
|
|
||||||
str = ObjectNames.NicifyVariableName(str);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string GetGameObjectValidatorName(IGameObjectValidator validator)
|
internal static string GetGameObjectValidatorName(IGameObjectValidator validator)
|
||||||
{
|
{
|
||||||
var str = validator.GetType().Name;
|
var str = validator.GetType().Name;
|
||||||
|
|
@ -204,93 +196,6 @@ namespace Module.ProjectValidator.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_6000_4_OR_NEWER
|
|
||||||
internal static void RebuildSceneInstanceMapping(Report report, Dictionary<EntityId, Report.MappingEntry> dictMapping)
|
|
||||||
{
|
|
||||||
dictMapping.Clear();
|
|
||||||
using var _ = ListPool<GameObject>.Get(out var rootObjects);
|
|
||||||
|
|
||||||
for (var i = 0; i < SceneManager.sceneCount; i++)
|
|
||||||
{
|
|
||||||
var scene = SceneManager.GetSceneAt(i);
|
|
||||||
|
|
||||||
if (!scene.isLoaded)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var strAssetGuid = AssetDatabase.AssetPathToGUID(scene.path);
|
|
||||||
GUID.TryParse(strAssetGuid, out var assetGuid);
|
|
||||||
scene.GetRootGameObjects(rootObjects);
|
|
||||||
|
|
||||||
for (var j = 0; j < rootObjects.Count; j++)
|
|
||||||
{
|
|
||||||
var rootObject = rootObjects[j];
|
|
||||||
var relativePath = string.Empty;
|
|
||||||
RebuildSceneInstanceMapping(report, dictMapping, rootObject, assetGuid, relativePath, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RebuildForAllParents(dictMapping);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static void RebuildSceneInstanceMapping(Report report, Dictionary<EntityId, Report.MappingEntry> dictMapping, GameObject gameObject, GUID assetGuid, string relativePath, bool initial)
|
|
||||||
{
|
|
||||||
var transform = gameObject.transform;
|
|
||||||
AppendToRelativePath(gameObject, ref relativePath, initial);
|
|
||||||
|
|
||||||
if (report.TryGetSeverityFor(assetGuid, relativePath, out var mapping))
|
|
||||||
dictMapping.Add(gameObject.GetEntityId(), new Report.MappingEntry(mapping.Severity, false));
|
|
||||||
|
|
||||||
for (var i = 0; i < transform.childCount; i++)
|
|
||||||
{
|
|
||||||
RebuildSceneInstanceMapping(report, dictMapping, transform.GetChild(i).gameObject, assetGuid, relativePath, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void RebuildForAllParents(Dictionary<EntityId, Report.MappingEntry> dictMapping)
|
|
||||||
{
|
|
||||||
using var _ = DictionaryPool<EntityId, Report.MappingEntry>.Get(out var newMappings);
|
|
||||||
|
|
||||||
foreach (var pair in dictMapping)
|
|
||||||
{
|
|
||||||
var obj = EditorUtility.EntityIdToObject(pair.Key);
|
|
||||||
|
|
||||||
if (obj is not GameObject gameObject)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var severity = pair.Value.Severity;
|
|
||||||
var transform = gameObject.transform.parent;
|
|
||||||
|
|
||||||
while (transform != null)
|
|
||||||
{
|
|
||||||
gameObject = transform.gameObject;
|
|
||||||
var entityId = gameObject.GetEntityId();
|
|
||||||
|
|
||||||
if (dictMapping.TryGetValue(entityId, out var parentMapping))
|
|
||||||
{
|
|
||||||
if (severity < parentMapping.Severity)
|
|
||||||
severity = parentMapping.Severity;
|
|
||||||
}
|
|
||||||
else if (newMappings.TryGetValue(entityId, out var currentMapping))
|
|
||||||
{
|
|
||||||
if (currentMapping.Severity < severity)
|
|
||||||
newMappings[entityId] = new Report.MappingEntry(severity, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newMappings.Add(entityId, new Report.MappingEntry(severity, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
transform = transform.parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var pair in newMappings)
|
|
||||||
{
|
|
||||||
dictMapping.Add(pair.Key, pair.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
internal static void RebuildSceneInstanceMapping(Report report, Dictionary<int, Report.MappingEntry> dictMapping)
|
internal static void RebuildSceneInstanceMapping(Report report, Dictionary<int, Report.MappingEntry> dictMapping)
|
||||||
{
|
{
|
||||||
dictMapping.Clear();
|
dictMapping.Clear();
|
||||||
|
|
@ -318,7 +223,6 @@ namespace Module.ProjectValidator.Editor
|
||||||
RebuildForAllParents(dictMapping);
|
RebuildForAllParents(dictMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void RebuildSceneInstanceMapping(Report report, Dictionary<int, Report.MappingEntry> dictMapping, GameObject gameObject, GUID assetGuid, string relativePath, bool initial)
|
private static void RebuildSceneInstanceMapping(Report report, Dictionary<int, Report.MappingEntry> dictMapping, GameObject gameObject, GUID assetGuid, string relativePath, bool initial)
|
||||||
{
|
{
|
||||||
var transform = gameObject.transform;
|
var transform = gameObject.transform;
|
||||||
|
|
@ -376,7 +280,6 @@ namespace Module.ProjectValidator.Editor
|
||||||
dictMapping.Add(pair.Key, pair.Value);
|
dictMapping.Add(pair.Key, pair.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
internal static void RefreshUnityWindows()
|
internal static void RefreshUnityWindows()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ namespace Module.ProjectValidator.Editor
|
||||||
{
|
{
|
||||||
internal static class ValidatorRunner
|
internal static class ValidatorRunner
|
||||||
{
|
{
|
||||||
|
private static bool _initialized;
|
||||||
private static ValidatorList _validatorList;
|
private static ValidatorList _validatorList;
|
||||||
private static TypeTree _typeTree;
|
private static TypeTree _typeTree;
|
||||||
|
|
||||||
|
|
@ -55,19 +56,21 @@ namespace Module.ProjectValidator.Editor
|
||||||
|
|
||||||
private static void Initialize()
|
private static void Initialize()
|
||||||
{
|
{
|
||||||
|
if (_initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
var settings = ProjectValidatorSettings.GetOrCreate();
|
var settings = ProjectValidatorSettings.GetOrCreate();
|
||||||
var assemblies = GetAssembliesFrom(settings);
|
var assemblies = GetAssembliesFrom(settings);
|
||||||
var enabled = GetEnabledValidators(settings);
|
|
||||||
|
|
||||||
_validatorList = new ValidatorList();
|
_validatorList = new ValidatorList();
|
||||||
_typeTree = new TypeTree();
|
_typeTree = new TypeTree();
|
||||||
|
|
||||||
FetchAllGameObjectValidators(enabled);
|
FetchAllGameObjectValidators();
|
||||||
FetchAllComponentValidators(enabled);
|
FetchAllComponentValidators();
|
||||||
FetchAllAttributeValidators(enabled);
|
FetchAllAttributeValidators();
|
||||||
FetchAllAssetValidators(enabled);
|
|
||||||
FetchAllTypesWithValidators<Component>(assemblies);
|
FetchAllTypesWithValidators<Component>(assemblies);
|
||||||
FetchAllTypesWithValidators<ScriptableObject>(assemblies);
|
FetchAllTypesWithValidators<ScriptableObject>(assemblies);
|
||||||
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Assembly[] GetAssembliesFrom(ProjectValidatorSettings settings)
|
private static Assembly[] GetAssembliesFrom(ProjectValidatorSettings settings)
|
||||||
|
|
@ -90,72 +93,33 @@ namespace Module.ProjectValidator.Editor
|
||||||
return assemblies.ToArray();
|
return assemblies.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashSet<Type> GetEnabledValidators(ProjectValidatorSettings settings)
|
private static void FetchAllAttributeValidators()
|
||||||
{
|
|
||||||
var enabled = new HashSet<Type>(settings.validators.Count);
|
|
||||||
|
|
||||||
for (var i = 0; i < settings.validators.Count; i++)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!settings.validators[i].enabled)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var type = Type.GetType(settings.validators[i].assemblyQualifiedName);
|
|
||||||
|
|
||||||
if (type != null)
|
|
||||||
enabled.Add(type);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void FetchAllAttributeValidators(HashSet<Type> enabled)
|
|
||||||
{
|
{
|
||||||
var types = TypeCache.GetTypesDerivedFrom(typeof(IAttributeValidator<>));
|
var types = TypeCache.GetTypesDerivedFrom(typeof(IAttributeValidator<>));
|
||||||
|
|
||||||
for (var i = 0; i < types.Count; i++)
|
for (var i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
if (enabled.Contains(types[i]))
|
_validatorList.AddAttribute(types[i]);
|
||||||
_validatorList.AddAttribute(types[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FetchAllGameObjectValidators(HashSet<Type> enabled)
|
private static void FetchAllGameObjectValidators()
|
||||||
{
|
{
|
||||||
var types = TypeCache.GetTypesDerivedFrom(typeof(IGameObjectValidator));
|
var types = TypeCache.GetTypesDerivedFrom(typeof(IGameObjectValidator));
|
||||||
|
|
||||||
for (var i = 0; i < types.Count; i++)
|
for (var i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
if (enabled.Contains(types[i]))
|
_validatorList.AddGameObject(types[i]);
|
||||||
_validatorList.AddGameObject(types[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FetchAllComponentValidators(HashSet<Type> enabled)
|
private static void FetchAllComponentValidators()
|
||||||
{
|
{
|
||||||
var types = TypeCache.GetTypesDerivedFrom(typeof(IComponentValidator<>));
|
var types = TypeCache.GetTypesDerivedFrom(typeof(IComponentValidator<>));
|
||||||
|
|
||||||
for (var i = 0; i < types.Count; i++)
|
for (var i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
if (enabled.Contains(types[i]))
|
_validatorList.AddComponent(types[i]);
|
||||||
_validatorList.AddComponent(types[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void FetchAllAssetValidators(HashSet<Type> enabled)
|
|
||||||
{
|
|
||||||
var types = TypeCache.GetTypesDerivedFrom(typeof(IAssetValidator<>));
|
|
||||||
|
|
||||||
for (var i = 0; i < types.Count; i++)
|
|
||||||
{
|
|
||||||
if (enabled.Contains(types[i]))
|
|
||||||
_validatorList.AddAsset(types[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,12 +143,12 @@ namespace Module.ProjectValidator.Editor
|
||||||
|
|
||||||
for (var i = 0; i < assets.Length; i++)
|
for (var i = 0; i < assets.Length; i++)
|
||||||
{
|
{
|
||||||
var assetPath = AssetDatabase.GetAssetPath(assets[i]);
|
|
||||||
var scene = SceneManager.GetSceneByPath(assetPath);
|
|
||||||
var isLoaded = scene.isLoaded;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var assetPath = AssetDatabase.GetAssetPath(assets[i]);
|
||||||
|
var scene = SceneManager.GetSceneByPath(assetPath);
|
||||||
|
var isLoaded = scene.isLoaded;
|
||||||
|
|
||||||
if (!isLoaded)
|
if (!isLoaded)
|
||||||
scene = EditorSceneManager.OpenScene(assetPath, OpenSceneMode.Additive);
|
scene = EditorSceneManager.OpenScene(assetPath, OpenSceneMode.Additive);
|
||||||
|
|
||||||
|
|
@ -192,43 +156,22 @@ namespace Module.ProjectValidator.Editor
|
||||||
|
|
||||||
for (var j = 0; j < rootObjects.Count; j++)
|
for (var j = 0; j < rootObjects.Count; j++)
|
||||||
{
|
{
|
||||||
ValidateGameObject(rootObjects[j], string.Empty, report, true);
|
ValidateGameObject(rootObjects[j], "scene:", report, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isLoaded)
|
||||||
|
EditorSceneManager.CloseScene(scene, true);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.LogException(e);
|
Debug.LogException(e);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (!isLoaded && scene.isLoaded)
|
|
||||||
EditorSceneManager.CloseScene(scene, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ValidateAllAssets(Report report)
|
private static void ValidateAllAssets(Report report)
|
||||||
{
|
{
|
||||||
ValidateAssetsBytype<ScriptableObject>(report);
|
ValidateAssetsBytype<ScriptableObject>(report);
|
||||||
|
|
||||||
foreach (var pair in _validatorList.AssetValidators)
|
|
||||||
{
|
|
||||||
var assets = EditorAssetUtility.LoadAllAssets(pair.Key);
|
|
||||||
|
|
||||||
for (var i = 0; i < assets.Length; i++)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var assetPath = AssetDatabase.GetAssetPath(assets[i]);
|
|
||||||
var assetGuid = AssetDatabase.GUIDFromAssetPath(assetPath);
|
|
||||||
ValidateAsset(assets[i], assetGuid, assetPath, pair.Value, report);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ValidateAllPrefabs(Report report)
|
private static void ValidateAllPrefabs(Report report)
|
||||||
|
|
@ -239,7 +182,7 @@ namespace Module.ProjectValidator.Editor
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ValidateGameObject(assets[i], string.Empty, report, true);
|
ValidateGameObject(assets[i], "prefab:", report, true);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -269,7 +212,7 @@ namespace Module.ProjectValidator.Editor
|
||||||
{
|
{
|
||||||
var assetGuid = EditorAssetUtility.ObjectToAssetGuid(obj);
|
var assetGuid = EditorAssetUtility.ObjectToAssetGuid(obj);
|
||||||
var assetPath = AssetDatabase.GUIDToAssetPath(assetGuid);
|
var assetPath = AssetDatabase.GUIDToAssetPath(assetGuid);
|
||||||
Validate(assetGuid, assetPath, obj, report);
|
Validate(assetGuid, $"asset:{assetPath}", obj, report);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ValidateGameObject(GameObject gameObject, string relativePath, Report report, bool initial)
|
private static void ValidateGameObject(GameObject gameObject, string relativePath, Report report, bool initial)
|
||||||
|
|
@ -311,29 +254,6 @@ namespace Module.ProjectValidator.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ValidateAsset(UnityEngine.Object obj, GUID assetGuid, string relativePath, List<ValidatorList.AssetValidator> validators, Report report)
|
|
||||||
{
|
|
||||||
using var _ = ListPool<ValidatorResult>.Get(out var results);
|
|
||||||
|
|
||||||
for (var i = 0; i < validators.Count; i++)
|
|
||||||
{
|
|
||||||
results.Clear();
|
|
||||||
var validator = validators[i];
|
|
||||||
validator.ValidatorMethod.Invoke(validator.Validator, new object[] { obj, results });
|
|
||||||
|
|
||||||
for (var j = 0; j < results.Count; j++)
|
|
||||||
{
|
|
||||||
var result = results[j];
|
|
||||||
|
|
||||||
if (result.Severity == EValidatorSeverity.Valid)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var validatorName = ProjectValidatorUtility.GetAssetValidatorName(validator.Validator);
|
|
||||||
report.Add(assetGuid, relativePath, string.Empty, validatorName, result.Severity, result.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ValidateChildren(GameObject gameObject, string relativePath, Report report)
|
private static void ValidateChildren(GameObject gameObject, string relativePath, Report report)
|
||||||
{
|
{
|
||||||
var transform = gameObject.transform;
|
var transform = gameObject.transform;
|
||||||
|
|
@ -424,17 +344,7 @@ namespace Module.ProjectValidator.Editor
|
||||||
var fieldPath = parentFieldPath;
|
var fieldPath = parentFieldPath;
|
||||||
ProjectValidatorUtility.AppendToFieldPath(e.FieldInfo, ref fieldPath);
|
ProjectValidatorUtility.AppendToFieldPath(e.FieldInfo, ref fieldPath);
|
||||||
|
|
||||||
if (value is Array arr)
|
if (value is IEnumerable<object> ie)
|
||||||
{
|
|
||||||
for (var j = 0; j < arr.Length; j++)
|
|
||||||
{
|
|
||||||
var eObj = arr.GetValue(j);
|
|
||||||
var fieldPathArrElement = fieldPath;
|
|
||||||
ProjectValidatorUtility.AppendToFieldPath(j, ref fieldPathArrElement);
|
|
||||||
Validate(assetGuid, relativePath, fieldPathArrElement, eObj, e.Entry, report);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (value is IEnumerable<object> ie)
|
|
||||||
{
|
{
|
||||||
var idx = 0;
|
var idx = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: ddbf30cd5a674751be0c125c1f4e917b
|
|
||||||
timeCreated: 1779623970
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
|
|
||||||
namespace Module.ProjectValidator.Editor
|
|
||||||
{
|
|
||||||
internal sealed class AssetValidatorMaterialShader : IAssetValidator<Material>
|
|
||||||
{
|
|
||||||
public void Validate(Material obj, List<ValidatorResult> results)
|
|
||||||
{
|
|
||||||
if (obj.shader == null)
|
|
||||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Error, "Shader is Null"));
|
|
||||||
else if (!IsCompatible(obj.shader))
|
|
||||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Warning, $"Shader '{obj.shader.name}' is not compatible with render pipeline"));
|
|
||||||
else if (!obj.shader.isSupported)
|
|
||||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Warning, $"Shader '{obj.shader.name}' is not supported"));
|
|
||||||
else if (ShaderUtil.ShaderHasError(obj.shader))
|
|
||||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Error, $"Shader '{obj.shader.name}' has compile errors"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool IsCompatible(Shader shader)
|
|
||||||
{
|
|
||||||
var pipeline = GraphicsSettings.currentRenderPipeline;
|
|
||||||
|
|
||||||
if (pipeline == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
var tagSearch = new ShaderTagId("RenderPipeline");
|
|
||||||
var tagPipeline = new ShaderTagId(pipeline.renderPipelineShaderTag);
|
|
||||||
var hasKeyword = false;
|
|
||||||
|
|
||||||
for (var i = 0; i < shader.passCount; i++)
|
|
||||||
{
|
|
||||||
var tagPass = shader.FindPassTagValue(i, tagSearch);
|
|
||||||
|
|
||||||
if (tagPass != ShaderTagId.none)
|
|
||||||
hasKeyword = true;
|
|
||||||
|
|
||||||
if (tagPass == tagPipeline)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return !hasKeyword;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 2218d247daff44bf84629756b63ea650
|
|
||||||
timeCreated: 1779623986
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
|
|
||||||
namespace Module.ProjectValidator.Editor
|
|
||||||
{
|
|
||||||
internal sealed class AssetValidatorMaterialTexture : IAssetValidator<Material>
|
|
||||||
{
|
|
||||||
public void Validate(Material obj, List<ValidatorResult> results)
|
|
||||||
{
|
|
||||||
if (obj.shader == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var count = obj.shader.GetPropertyCount();
|
|
||||||
|
|
||||||
for (var i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
var propertyType = obj.shader.GetPropertyType(i);
|
|
||||||
var propertyFlags = obj.shader.GetPropertyFlags(i);
|
|
||||||
|
|
||||||
if (propertyType != ShaderPropertyType.Texture)
|
|
||||||
continue;
|
|
||||||
if ((propertyFlags & (ShaderPropertyFlags.PerRendererData | ShaderPropertyFlags.HideInInspector | ShaderPropertyFlags.NonModifiableTextureData)) != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var propertyName = obj.shader.GetPropertyName(i);
|
|
||||||
var propertyValue = obj.GetTexture(propertyName);
|
|
||||||
|
|
||||||
if (propertyValue == null)
|
|
||||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Warning, $"Texture property '{propertyName}' is Null"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: cfeb4b29a9cd4ea79c1e9325b8122e17
|
|
||||||
timeCreated: 1779627240
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Module.ProjectValidator.Editor
|
|
||||||
{
|
|
||||||
internal sealed class AttributeValidatorObsolete : IAttributeValidator<ObsoleteAttribute>
|
|
||||||
{
|
|
||||||
public ValidatorResult Validate(ObsoleteAttribute attribute, object value)
|
|
||||||
{
|
|
||||||
return ValidatorResult.Create(EValidatorSeverity.Error, "Obsolete");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 982ac4e898cc2ca438e98a2f0034a8d3
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Pool;
|
using UnityEngine.Pool;
|
||||||
|
|
||||||
|
|
@ -30,7 +28,7 @@ namespace Module.ProjectValidator.Editor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (count > 1 && IsMultipleComponentsAllowed(type))
|
if (count > 1)
|
||||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Warning, $"GameObject has duplicate '{type.Name}' ({count}) components"));
|
results.Add(ValidatorResult.Create(EValidatorSeverity.Warning, $"GameObject has duplicate '{type.Name}' ({count}) components"));
|
||||||
|
|
||||||
type = t;
|
type = t;
|
||||||
|
|
@ -38,13 +36,8 @@ namespace Module.ProjectValidator.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > 1 && IsMultipleComponentsAllowed(type))
|
if (count > 1)
|
||||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Warning, $"GameObject has duplicate '{type.Name}' ({count}) components"));
|
results.Add(ValidatorResult.Create(EValidatorSeverity.Warning, $"GameObject has duplicate '{type.Name}' ({count}) components"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsMultipleComponentsAllowed(Type type)
|
|
||||||
{
|
|
||||||
return type.GetCustomAttribute<DisallowMultipleComponent>(true) == null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Module.ProjectValidator.Editor
|
|
||||||
{
|
|
||||||
internal sealed class GameObjectValidatorTransform : IGameObjectValidator
|
|
||||||
{
|
|
||||||
public void Validate(GameObject gameObject, List<ValidatorResult> results)
|
|
||||||
{
|
|
||||||
var transform = gameObject.transform;
|
|
||||||
var lp = transform.localPosition;
|
|
||||||
var lr = transform.localRotation;
|
|
||||||
var ls = transform.localScale;
|
|
||||||
|
|
||||||
if (IsInvalid(lp.x) || IsInvalid(lp.y) || IsInvalid(lp.z))
|
|
||||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Error, $"Local position '{lp}' is invalid"));
|
|
||||||
if (IsInvalid(lr.x) || IsInvalid(lr.y) || IsInvalid(lr.z) || IsInvalid(lr.w))
|
|
||||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Error, $"Local rotation '{lr}' is invalid"));
|
|
||||||
if (IsInvalid(ls.x) || IsInvalid(ls.y) || IsInvalid(ls.z))
|
|
||||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Error, $"Local scale '{ls}' is invalid"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool IsInvalid(float value)
|
|
||||||
{
|
|
||||||
return float.IsNaN(value) || float.IsInfinity(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 727d5de59b004deb8c192337bcee132e
|
|
||||||
timeCreated: 1779628852
|
|
||||||
|
|
@ -8,12 +8,6 @@ namespace Module.ProjectValidator.Editor
|
||||||
{
|
{
|
||||||
internal sealed class EditorProjectValidatorWindow : EditorWindow
|
internal sealed class EditorProjectValidatorWindow : EditorWindow
|
||||||
{
|
{
|
||||||
private VisualElement _groupWarnings;
|
|
||||||
private Label _labelWarnings;
|
|
||||||
|
|
||||||
private VisualElement _groupErrors;
|
|
||||||
private Label _labelErrors;
|
|
||||||
|
|
||||||
private MultiColumnTreeView _treeView;
|
private MultiColumnTreeView _treeView;
|
||||||
private string _searchFilter;
|
private string _searchFilter;
|
||||||
|
|
||||||
|
|
@ -27,19 +21,9 @@ namespace Module.ProjectValidator.Editor
|
||||||
root.styleSheets.Add(EditorAssetUtility.LoadFirstAsset<StyleSheet>("StyleSheetEditorProjectValidatorWindow"));
|
root.styleSheets.Add(EditorAssetUtility.LoadFirstAsset<StyleSheet>("StyleSheetEditorProjectValidatorWindow"));
|
||||||
root.Add(asset.Instantiate());
|
root.Add(asset.Instantiate());
|
||||||
|
|
||||||
_groupWarnings = root.Q<VisualElement>("status-warnings");
|
|
||||||
_labelWarnings = _groupWarnings.Q<Label>("label-warnings");
|
|
||||||
|
|
||||||
_groupErrors = root.Q<VisualElement>("status-errors");
|
|
||||||
_labelErrors = _groupErrors.Q<Label>("label-errors");
|
|
||||||
|
|
||||||
_groupWarnings.style.display = DisplayStyle.None;
|
|
||||||
_groupErrors.style.display = DisplayStyle.None;
|
|
||||||
|
|
||||||
root.Q<ToolbarButton>("button-run").clicked += OnToolbarButtonRunClicked;
|
root.Q<ToolbarButton>("button-run").clicked += OnToolbarButtonRunClicked;
|
||||||
root.Q<ToolbarButton>("button-clear").clicked += OnToolbarButtonClearClicked;
|
root.Q<ToolbarButton>("button-clear").clicked += OnToolbarButtonClearClicked;
|
||||||
root.Q<ToolbarSearchField>().RegisterValueChangedCallback(OnToolbarSearchFieldChanged);
|
root.Q<ToolbarSearchField>().RegisterValueChangedCallback(OnToolbarSearchFieldChanged);
|
||||||
root.Q<ToolbarButton>("button-settings").clicked += OnToolbarButtonSettingsClicked;
|
|
||||||
|
|
||||||
_treeView = root.Q<MultiColumnTreeView>();
|
_treeView = root.Q<MultiColumnTreeView>();
|
||||||
_treeView.columns["asset"].makeCell = CreateObjectField;
|
_treeView.columns["asset"].makeCell = CreateObjectField;
|
||||||
|
|
@ -76,26 +60,11 @@ namespace Module.ProjectValidator.Editor
|
||||||
|
|
||||||
_list.Clear();
|
_list.Clear();
|
||||||
|
|
||||||
var entries = Report.Active.Entries;
|
for (var i = 0; i < Report.Active.Entries.Count; i++)
|
||||||
var warningCount = 0;
|
|
||||||
var errorCount = 0;
|
|
||||||
|
|
||||||
for (var i = 0; i < entries.Count; i++)
|
|
||||||
{
|
{
|
||||||
_list.Add(new TreeViewItemData<Report.Entry>(i, entries[i]));
|
_list.Add(new TreeViewItemData<Report.Entry>(i, Report.Active.Entries[i]));
|
||||||
|
|
||||||
if (entries[i].Severity == EValidatorSeverity.Warning)
|
|
||||||
warningCount++;
|
|
||||||
if (entries[i].Severity == EValidatorSeverity.Error)
|
|
||||||
errorCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_groupWarnings.style.display = warningCount > 0 ? DisplayStyle.Flex : DisplayStyle.None;
|
|
||||||
_labelWarnings.text = warningCount.ToString();
|
|
||||||
|
|
||||||
_groupErrors.style.display = errorCount > 0 ? DisplayStyle.Flex : DisplayStyle.None;
|
|
||||||
_labelErrors.text = errorCount.ToString();
|
|
||||||
|
|
||||||
Filter();
|
Filter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,16 +123,9 @@ namespace Module.ProjectValidator.Editor
|
||||||
|
|
||||||
private void OnToolbarButtonClearClicked()
|
private void OnToolbarButtonClearClicked()
|
||||||
{
|
{
|
||||||
_groupWarnings.style.display = DisplayStyle.None;
|
|
||||||
_groupErrors.style.display = DisplayStyle.None;
|
|
||||||
ValidatorRunner.Clear();
|
ValidatorRunner.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnToolbarButtonSettingsClicked()
|
|
||||||
{
|
|
||||||
SettingsService.OpenProjectSettings(ProjectValidatorSettings.MenuPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnToolbarSearchFieldChanged(ChangeEvent<string> evt)
|
private void OnToolbarSearchFieldChanged(ChangeEvent<string> evt)
|
||||||
{
|
{
|
||||||
_searchFilter = evt.newValue;
|
_searchFilter = evt.newValue;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: a22633e08b3d4c0fbbea654a8a8cd287
|
|
||||||
timeCreated: 1779637991
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
using UnityEditor;
|
|
||||||
using UnityEditor.UIElements;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
namespace Module.ProjectValidator.Editor
|
|
||||||
{
|
|
||||||
[CustomPropertyDrawer(typeof(ProjectValidatorSettings.ValidatorEnabled))]
|
|
||||||
internal sealed class EditorProjectValidatorEnabledPropertyDrawer : PropertyDrawer
|
|
||||||
{
|
|
||||||
public override VisualElement CreatePropertyGUI(SerializedProperty property)
|
|
||||||
{
|
|
||||||
var spType = property.FindPropertyRelative(nameof(ProjectValidatorSettings.ValidatorEnabled.name));
|
|
||||||
var spEnabled = property.FindPropertyRelative(nameof(ProjectValidatorSettings.ValidatorEnabled.enabled));
|
|
||||||
|
|
||||||
var root = new VisualElement { style = { flexDirection = FlexDirection.Row } };
|
|
||||||
var veType = new PropertyField(spType, string.Empty) { style = { flexGrow = 1f }, enabledSelf = false };
|
|
||||||
var veEnabled = new PropertyField(spEnabled, string.Empty);
|
|
||||||
root.Add(veEnabled);
|
|
||||||
root.Add(veType);
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: e6c8cb829f514028b705bf121373c67c
|
|
||||||
timeCreated: 1779638011
|
|
||||||
|
|
@ -16,39 +16,4 @@
|
||||||
-unity-font-style: bold;
|
-unity-font-style: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toolbar-button-settings {
|
|
||||||
width: 24px;
|
|
||||||
min-width: 24px;
|
|
||||||
max-width: 24px;
|
|
||||||
padding-top: 0;
|
|
||||||
padding-right: 0;
|
|
||||||
padding-bottom: 0;
|
|
||||||
padding-left: 0;
|
|
||||||
background-image: url("project://database/Packages/com.module.project-validator/Editor/Icons/editor_project_validator_settings.png?fileID=2800000&guid=a6c61d5fbd310894d8159ba6af32d7e3&type=3#editor_project_validator_settings");
|
|
||||||
-unity-background-scale-mode: scale-to-fit;
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.warning-icon {
|
|
||||||
background-image: url("project://database/Packages/com.module.project-validator/Editor/Icons/editor_project_validator_warning.png?fileID=2800000&guid=5dce0f250980ffb459470fac33dfab59&type=3#editor_project_validator_warning");
|
|
||||||
width: 16px;
|
|
||||||
min-width: 16px;
|
|
||||||
max-width: 16px;
|
|
||||||
max-height: 16px;
|
|
||||||
min-height: 16px;
|
|
||||||
height: 16px;
|
|
||||||
-unity-background-scale-mode: scale-to-fit;
|
|
||||||
margin-left: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.error-icon {
|
|
||||||
background-image: url("project://database/Packages/com.module.project-validator/Editor/Icons/editor_project_validator_error.png?fileID=2800000&guid=7b6c61a2cf824b74c87cb49759531c79&type=3#editor_project_validator_error");
|
|
||||||
width: 16px;
|
|
||||||
min-width: 16px;
|
|
||||||
max-width: 16px;
|
|
||||||
max-height: 16px;
|
|
||||||
min-height: 16px;
|
|
||||||
height: 16px;
|
|
||||||
-unity-background-scale-mode: scale-to-fit;
|
|
||||||
margin-left: 4px;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,8 @@
|
||||||
<uie:Toolbar name="toolbar">
|
<uie:Toolbar name="toolbar">
|
||||||
<uie:ToolbarButton text="Run" name="button-run" style="margin-left: 2px;"/>
|
<uie:ToolbarButton text="Run" name="button-run" style="margin-left: 2px;"/>
|
||||||
<uie:ToolbarButton text="Clear" name="button-clear"/>
|
<uie:ToolbarButton text="Clear" name="button-clear"/>
|
||||||
<uie:ToolbarSpacer name="spacing" style="flex-grow: 1;"/>
|
<uie:ToolbarSpacer style="flex-grow: 1;"/>
|
||||||
<ui:VisualElement name="status-errors" style="flex-grow: 0; flex-direction: row; align-self: center; margin-left: 4px;">
|
|
||||||
<ui:Label text="9999" name="label-errors" double-click-selects-word="false" triple-click-selects-line="false" display-tooltip-when-elided="false" style="flex-grow: 1; -unity-text-align: middle-center;"/>
|
|
||||||
<ui:VisualElement name="icon" class="error-icon" style="flex-grow: 1;"/>
|
|
||||||
</ui:VisualElement>
|
|
||||||
<ui:VisualElement name="status-warnings" style="flex-grow: 0; flex-direction: row; align-self: center; margin-right: 4px;">
|
|
||||||
<ui:Label text="9999" name="label-warnings" double-click-selects-word="false" triple-click-selects-line="false" display-tooltip-when-elided="false" style="flex-grow: 1; -unity-text-align: middle-center;"/>
|
|
||||||
<ui:VisualElement name="icon" class="warning-icon" style="flex-grow: 1;"/>
|
|
||||||
</ui:VisualElement>
|
|
||||||
<uie:ToolbarSpacer name="spacing" style="flex-grow: 1;"/>
|
|
||||||
<uie:ToolbarSearchField name="search-field"/>
|
<uie:ToolbarSearchField name="search-field"/>
|
||||||
<uie:ToolbarButton text="" name="button-settings" class="toolbar-button-settings"/>
|
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
<ui:MultiColumnTreeView columns="" sort-column-descriptions="" name="tree-view" show-alternating-row-backgrounds="All" data-source-type="Module.ProjectValidator.Editor.Report+Entry, Module.ProjectValidator.Editor" sorting-mode="Default" class="tree-view">
|
<ui:MultiColumnTreeView columns="" sort-column-descriptions="" name="tree-view" show-alternating-row-backgrounds="All" data-source-type="Module.ProjectValidator.Editor.Report+Entry, Module.ProjectValidator.Editor" sorting-mode="Default" class="tree-view">
|
||||||
<ui:Columns reorderable="false" primary-column-name="severity">
|
<ui:Columns reorderable="false" primary-column-name="severity">
|
||||||
|
|
@ -26,5 +16,4 @@
|
||||||
</ui:Columns>
|
</ui:Columns>
|
||||||
<ui:SortColumnDescriptions/>
|
<ui:SortColumnDescriptions/>
|
||||||
</ui:MultiColumnTreeView>
|
</ui:MultiColumnTreeView>
|
||||||
<ui:Image/>
|
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|
|
||||||
45
README.md
45
README.md
|
|
@ -1,50 +1,15 @@
|
||||||
# Description
|
# Description
|
||||||
|
|
||||||
A tool to help validate data across scenes, prefabs, scriptable objects and assets.
|
A tool to help validate data across scenes, prefabs and scriptable objects.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Unity Windows
|
### Unity Windows
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
## Settings
|
## Game Object Validators
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
## Validators
|
|
||||||
|
|
||||||
### Asset Validators
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
public sealed class AssetValidatorMaterialTexture : IAssetValidator<Material>
|
|
||||||
{
|
|
||||||
public void Validate(Material obj, List<ValidatorResult> results)
|
|
||||||
{
|
|
||||||
if (obj.shader == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var count = obj.shader.GetPropertyCount();
|
|
||||||
|
|
||||||
for (var i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
var propertyType = obj.shader.GetPropertyType(i);
|
|
||||||
|
|
||||||
if (propertyType != ShaderPropertyType.Texture)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var propertyName = obj.shader.GetPropertyName(i);
|
|
||||||
var propertyValue = obj.GetTexture(propertyName);
|
|
||||||
|
|
||||||
if (propertyValue == null)
|
|
||||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Warning, $"Texture property '{propertyName}' is Null"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Game Object Validators
|
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
public sealed class GameObjectValidatorBrokenPrefab : IGameObjectValidator
|
public sealed class GameObjectValidatorBrokenPrefab : IGameObjectValidator
|
||||||
|
|
@ -57,7 +22,7 @@ public sealed class GameObjectValidatorBrokenPrefab : IGameObjectValidator
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Component Validators
|
## Component Validators
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
public sealed class ComponentValidatorMeshCollider : IComponentValidator<MeshCollider>
|
public sealed class ComponentValidatorMeshCollider : IComponentValidator<MeshCollider>
|
||||||
|
|
@ -70,7 +35,7 @@ public sealed class ComponentValidatorMeshCollider : IComponentValidator<MeshCol
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Attribute Validators
|
## Attribute Validators
|
||||||
|
|
||||||
The field attribute:
|
The field attribute:
|
||||||
```csharp
|
```csharp
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Module.ProjectValidator
|
|
||||||
{
|
|
||||||
public interface IAssetValidator<in T> where T : Object
|
|
||||||
{
|
|
||||||
void Validate(T obj, List<ValidatorResult> results);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 24ee414b7fa14a368a48cab1b608ee3b
|
|
||||||
timeCreated: 1779624012
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "com.module.project-validator",
|
"name": "com.module.project-validator",
|
||||||
"version": "1.0.3",
|
"version": "0.5.0",
|
||||||
"displayName": "Module.ProjectValidator",
|
"displayName": "Module.ProjectValidator",
|
||||||
"description": "",
|
"description": "",
|
||||||
"unity": "6000.3",
|
"unity": "6000.3",
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 34 KiB |
|
|
@ -1,117 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 094f9567dcf756b468ea41cd471b65d7
|
|
||||||
TextureImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 13
|
|
||||||
mipmaps:
|
|
||||||
mipMapMode: 0
|
|
||||||
enableMipMap: 1
|
|
||||||
sRGBTexture: 1
|
|
||||||
linearTexture: 0
|
|
||||||
fadeOut: 0
|
|
||||||
borderMipMap: 0
|
|
||||||
mipMapsPreserveCoverage: 0
|
|
||||||
alphaTestReferenceValue: 0.5
|
|
||||||
mipMapFadeDistanceStart: 1
|
|
||||||
mipMapFadeDistanceEnd: 3
|
|
||||||
bumpmap:
|
|
||||||
convertToNormalMap: 0
|
|
||||||
externalNormalMap: 0
|
|
||||||
heightScale: 0.25
|
|
||||||
normalMapFilter: 0
|
|
||||||
flipGreenChannel: 0
|
|
||||||
isReadable: 0
|
|
||||||
streamingMipmaps: 0
|
|
||||||
streamingMipmapsPriority: 0
|
|
||||||
vTOnly: 0
|
|
||||||
ignoreMipmapLimit: 0
|
|
||||||
grayScaleToAlpha: 0
|
|
||||||
generateCubemap: 6
|
|
||||||
cubemapConvolution: 0
|
|
||||||
seamlessCubemap: 0
|
|
||||||
textureFormat: 1
|
|
||||||
maxTextureSize: 2048
|
|
||||||
textureSettings:
|
|
||||||
serializedVersion: 2
|
|
||||||
filterMode: 1
|
|
||||||
aniso: 1
|
|
||||||
mipBias: 0
|
|
||||||
wrapU: 0
|
|
||||||
wrapV: 0
|
|
||||||
wrapW: 0
|
|
||||||
nPOTScale: 1
|
|
||||||
lightmap: 0
|
|
||||||
compressionQuality: 50
|
|
||||||
spriteMode: 0
|
|
||||||
spriteExtrude: 1
|
|
||||||
spriteMeshType: 1
|
|
||||||
alignment: 0
|
|
||||||
spritePivot: {x: 0.5, y: 0.5}
|
|
||||||
spritePixelsToUnits: 100
|
|
||||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
spriteGenerateFallbackPhysicsShape: 1
|
|
||||||
alphaUsage: 1
|
|
||||||
alphaIsTransparency: 0
|
|
||||||
spriteTessellationDetail: -1
|
|
||||||
textureType: 0
|
|
||||||
textureShape: 1
|
|
||||||
singleChannelComponent: 0
|
|
||||||
flipbookRows: 1
|
|
||||||
flipbookColumns: 1
|
|
||||||
maxTextureSizeSet: 0
|
|
||||||
compressionQualitySet: 0
|
|
||||||
textureFormatSet: 0
|
|
||||||
ignorePngGamma: 0
|
|
||||||
applyGammaDecoding: 0
|
|
||||||
swizzle: 50462976
|
|
||||||
cookieLightType: 0
|
|
||||||
platformSettings:
|
|
||||||
- serializedVersion: 4
|
|
||||||
buildTarget: DefaultTexturePlatform
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
ignorePlatformSupport: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 4
|
|
||||||
buildTarget: Standalone
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
ignorePlatformSupport: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
spriteSheet:
|
|
||||||
serializedVersion: 2
|
|
||||||
sprites: []
|
|
||||||
outline: []
|
|
||||||
customData:
|
|
||||||
physicsShape: []
|
|
||||||
bones: []
|
|
||||||
spriteID:
|
|
||||||
internalID: 0
|
|
||||||
vertices: []
|
|
||||||
indices:
|
|
||||||
edges: []
|
|
||||||
weights: []
|
|
||||||
secondaryTextures: []
|
|
||||||
spriteCustomMetadata:
|
|
||||||
entries: []
|
|
||||||
nameFileIdTable: {}
|
|
||||||
mipmapLimitGroupName:
|
|
||||||
pSDRemoveMatte: 0
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 154 KiB After Width: | Height: | Size: 154 KiB |
Loading…
Add table
Add a link
Reference in a new issue