1
0
mirror of https://github.com/maxartz15/Validator.git synced 2024-11-24 21:05:47 +01:00

Compare commits

..

No commits in common. "5b70e24c3226858428e08169b5060e74e26255e7" and "8399d043f567ac1107954ff9f44fc6f6a5237a67" have entirely different histories.

10 changed files with 413 additions and 413 deletions

View File

@ -4,13 +4,13 @@ using UnityEngine;
namespace Validator.Editor
{
public class ValidatableAssetValidator : IValidator
public class AssetValidator : IValidator
{
public string MenuName => nameof(ValidatableAssetValidator);
public string MenuName => nameof(AssetValidator);
public Report Validate()
{
Report report = new Report(nameof(ValidatableAssetValidator));
Report report = new Report(nameof(AssetValidator));
List<Object> objects = FindAssetsByType<Object>();
for (int i = 0; i < objects.Count; i++)

View File

@ -8,7 +8,7 @@ namespace Validator.Editor
{
public class RequiredAttributeAssetValidator : IValidator
{
public string MenuName => nameof(RequiredAttributeAssetValidator);
public string MenuName => "Attributes/RequiredAttributeAssetValidator";
private const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
@ -16,7 +16,7 @@ namespace Validator.Editor
{
Report report = new Report(nameof(RequiredAttributeAssetValidator));
List<Object> objects = ValidatableAssetValidator.FindAssetsByType<Object>();
List<Object> objects = AssetValidator.FindAssetsByType<Object>();
for (int i = 0; i < objects.Count; i++)
{
@ -44,7 +44,7 @@ namespace Validator.Editor
public class RequiredAttributeSceneValidator : IValidator
{
public string MenuName => nameof(RequiredAttributeSceneValidator);
public string MenuName => "Attributes/RequiredAttributeSceneValidator";
private const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
@ -52,7 +52,7 @@ namespace Validator.Editor
{
Report report = new Report(nameof(RequiredAttributeSceneValidator));
List<MonoBehaviour> objects = ValidatableSceneValidator.FindAllObjectsOfType<MonoBehaviour>();
List<MonoBehaviour> objects = SceneValidator.FindAllObjectsOfType<MonoBehaviour>();
for (int i = 0; i < objects.Count; i++)
{

View File

@ -0,0 +1,57 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Validator.Editor
{
public class SceneValidator : IValidator
{
public string MenuName => nameof(SceneValidator);
public Report Validate()
{
Report report = new Report(nameof(SceneValidator));
List<IValidatable> objects = FindAllObjectsOfType<IValidatable>();
for (int i = 0; i < objects.Count; i++)
{
EditorUtility.DisplayProgressBar("SceneValidator", "Validate...", (float)i / objects.Count);
objects[i].Validate(report);
}
EditorUtility.ClearProgressBar();
return report;
}
private static List<GameObject> GetAllRootGameObjects()
{
List<GameObject> gameObjects = new List<GameObject>();
for (int i = 0; i < SceneManager.sceneCount; i++)
{
EditorUtility.DisplayProgressBar("SceneValidator", "GetAllRootGameObjects...", (float)i / SceneManager.sceneCount);
gameObjects.AddRange(SceneManager.GetSceneAt(i).GetRootGameObjects());
}
EditorUtility.ClearProgressBar();
return gameObjects;
}
public static List<T> FindAllObjectsOfType<T>()
{
List<T> objects = new List<T>();
List<GameObject> gameObjects = GetAllRootGameObjects();
for (int i = 0; i < gameObjects.Count; i++)
{
EditorUtility.DisplayProgressBar("SceneValidator", "FindAllObjectsOfType...", (float)i / gameObjects.Count);
objects.AddRange(gameObjects[i].GetComponentsInChildren<T>(true));
}
EditorUtility.ClearProgressBar();
return objects;
}
}
}

View File

@ -1,57 +0,0 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Validator.Editor
{
public class ValidatableSceneValidator : IValidator
{
public string MenuName => nameof(ValidatableSceneValidator);
public Report Validate()
{
Report report = new Report(nameof(ValidatableSceneValidator));
List<IValidatable> objects = FindAllObjectsOfType<IValidatable>();
for (int i = 0; i < objects.Count; i++)
{
EditorUtility.DisplayProgressBar("SceneValidator", "Validate...", (float)i / objects.Count);
objects[i].Validate(report);
}
EditorUtility.ClearProgressBar();
return report;
}
private static List<GameObject> GetAllRootGameObjects()
{
List<GameObject> gameObjects = new List<GameObject>();
for (int i = 0; i < SceneManager.sceneCount; i++)
{
EditorUtility.DisplayProgressBar("SceneValidator", "GetAllRootGameObjects...", (float)i / SceneManager.sceneCount);
gameObjects.AddRange(SceneManager.GetSceneAt(i).GetRootGameObjects());
}
EditorUtility.ClearProgressBar();
return gameObjects;
}
public static List<T> FindAllObjectsOfType<T>()
{
List<T> objects = new List<T>();
List<GameObject> gameObjects = GetAllRootGameObjects();
for (int i = 0; i < gameObjects.Count; i++)
{
EditorUtility.DisplayProgressBar("SceneValidator", "FindAllObjectsOfType...", (float)i / gameObjects.Count);
objects.AddRange(gameObjects[i].GetComponentsInChildren<T>(true));
}
EditorUtility.ClearProgressBar();
return objects;
}
}
}