Fixed issue, where the validator enabled state couldn't be loaded correctly, if in another assembly
This commit is contained in:
parent
ddb4fc25ea
commit
58acb2979d
5 changed files with 135 additions and 11 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue