Fixed issue, where the validator enabled state couldn't be loaded correctly, if in another assembly

This commit is contained in:
Anders Ejlersen 2026-05-24 23:09:47 +02:00
parent ddb4fc25ea
commit 58acb2979d
5 changed files with 135 additions and 11 deletions

View file

@ -13,6 +13,7 @@ namespace Module.ProjectValidator.Editor
internal sealed class ProjectValidatorSettings : ScriptableObject
{
public List<string> assemblies = new();
[NonReorderable]
public List<ValidatorEnabled> validators = new();
public const string MenuPath = "Project/Project Validator";
@ -74,13 +75,17 @@ namespace Module.ProjectValidator.Editor
for (var i = 0; i < settings.validators.Count; i++)
{
temp.Add(settings.validators[i].type);
temp.Add(settings.validators[i].assemblyQualifiedName);
}
for (var i = 0; i < list.Count; i++)
{
if (!temp.Contains(list[i]))
settings.validators.Add(new ValidatorEnabled(list[i], true));
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--)
@ -97,19 +102,21 @@ namespace Module.ProjectValidator.Editor
for (var i = 0; i < types.Count; i++)
{
if (!types[i].IsInterface && !types[i].IsAbstract)
typeNames.Add(types[i].FullName);
typeNames.Add(types[i].AssemblyQualifiedName);
}
}
[Serializable]
public sealed class ValidatorEnabled
{
public string type;
public string name;
public string assemblyQualifiedName;
public bool enabled;
public ValidatorEnabled(string type, bool enabled)
public ValidatorEnabled(string name, string assemblyQualifiedName, bool enabled)
{
this.type = type;
this.name = name;
this.assemblyQualifiedName = assemblyQualifiedName;
this.enabled = enabled;
}
}

View file

@ -101,7 +101,7 @@ namespace Module.ProjectValidator.Editor
if (!settings.validators[i].enabled)
continue;
var type = Type.GetType(settings.validators[i].type);
var type = Type.GetType(settings.validators[i].assemblyQualifiedName);
if (type != null)
enabled.Add(type);

View file

@ -9,11 +9,11 @@ namespace Module.ProjectValidator.Editor
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var spType = property.FindPropertyRelative(nameof(ProjectValidatorSettings.ValidatorEnabled.type));
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 } };
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);

View file

@ -1,6 +1,6 @@
{
"name": "com.module.project-validator",
"version": "1.0.0",
"version": "1.0.1",
"displayName": "Module.ProjectValidator",
"description": "",
"unity": "6000.3",

View file

@ -0,0 +1,117 @@
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: