- Validator: Added asset validators with material texture and shader validation
- Validator: Added option to enable/disable certain validators - Project Settings: Fixed issue, where changes weren't always saved - Unity: Removed deprecated warnings in Unity 6.4
This commit is contained in:
parent
01ac17a078
commit
dd55a87740
30 changed files with 716 additions and 38 deletions
|
|
@ -1,7 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Module.ProjectValidator.Editor
|
||||
{
|
||||
|
|
@ -29,6 +31,22 @@ namespace Module.ProjectValidator.Editor
|
|||
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)
|
||||
{
|
||||
var assetPath = string.Empty;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,14 @@ namespace Module.ProjectValidator.Editor
|
|||
window.titleContent = new GUIContent("Project Validator");
|
||||
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)
|
||||
{
|
||||
|
|
@ -196,6 +204,93 @@ 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)
|
||||
{
|
||||
dictMapping.Clear();
|
||||
|
|
@ -223,6 +318,7 @@ namespace Module.ProjectValidator.Editor
|
|||
RebuildForAllParents(dictMapping);
|
||||
}
|
||||
|
||||
|
||||
private static void RebuildSceneInstanceMapping(Report report, Dictionary<int, Report.MappingEntry> dictMapping, GameObject gameObject, GUID assetGuid, string relativePath, bool initial)
|
||||
{
|
||||
var transform = gameObject.transform;
|
||||
|
|
@ -280,6 +376,7 @@ namespace Module.ProjectValidator.Editor
|
|||
dictMapping.Add(pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
internal static void RefreshUnityWindows()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue