Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eb46c22ffc | |||
| 9dd45f536e | |||
| 3802ca557c |
8 changed files with 112 additions and 22 deletions
|
|
@ -179,12 +179,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);
|
||||||
|
|
||||||
|
|
@ -194,14 +194,16 @@ namespace Module.ProjectValidator.Editor
|
||||||
{
|
{
|
||||||
ValidateGameObject(rootObjects[j], string.Empty, report, true);
|
ValidateGameObject(rootObjects[j], string.Empty, 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -421,8 +423,18 @@ 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 IEnumerable<object> ie)
|
if (value is Array arr)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,16 +28,20 @@ namespace Module.ProjectValidator.Editor
|
||||||
|
|
||||||
var tagSearch = new ShaderTagId("RenderPipeline");
|
var tagSearch = new ShaderTagId("RenderPipeline");
|
||||||
var tagPipeline = new ShaderTagId(pipeline.renderPipelineShaderTag);
|
var tagPipeline = new ShaderTagId(pipeline.renderPipelineShaderTag);
|
||||||
|
var hasKeyword = false;
|
||||||
|
|
||||||
for (var i = 0; i < shader.passCount; i++)
|
for (var i = 0; i < shader.passCount; i++)
|
||||||
{
|
{
|
||||||
var tagPass = shader.FindPassTagValue(i, tagSearch);
|
var tagPass = shader.FindPassTagValue(i, tagSearch);
|
||||||
|
|
||||||
|
if (tagPass != ShaderTagId.none)
|
||||||
|
hasKeyword = true;
|
||||||
|
|
||||||
if (tagPass == tagPipeline)
|
if (tagPass == tagPipeline)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return !hasKeyword;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -16,10 +16,13 @@ namespace Module.ProjectValidator.Editor
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
var propertyType = obj.shader.GetPropertyType(i);
|
var propertyType = obj.shader.GetPropertyType(i);
|
||||||
|
var propertyFlags = obj.shader.GetPropertyFlags(i);
|
||||||
|
|
||||||
if (propertyType != ShaderPropertyType.Texture)
|
if (propertyType != ShaderPropertyType.Texture)
|
||||||
continue;
|
continue;
|
||||||
|
if ((propertyFlags & (ShaderPropertyFlags.PerRendererData | ShaderPropertyFlags.HideInInspector | ShaderPropertyFlags.NonModifiableTextureData)) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
var propertyName = obj.shader.GetPropertyName(i);
|
var propertyName = obj.shader.GetPropertyName(i);
|
||||||
var propertyValue = obj.GetTexture(propertyName);
|
var propertyValue = obj.GetTexture(propertyName);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Pool;
|
using UnityEngine.Pool;
|
||||||
|
|
||||||
|
|
@ -28,7 +30,7 @@ namespace Module.ProjectValidator.Editor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (count > 1)
|
if (count > 1 && IsMultipleComponentsAllowed(type))
|
||||||
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;
|
||||||
|
|
@ -36,8 +38,13 @@ namespace Module.ProjectValidator.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > 1)
|
if (count > 1 && IsMultipleComponentsAllowed(type))
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8,12 +8,18 @@ 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;
|
||||||
|
|
||||||
private readonly List<TreeViewItemData<Report.Entry>> _list = new();
|
private readonly List<TreeViewItemData<Report.Entry>> _list = new();
|
||||||
private readonly List<TreeViewItemData<Report.Entry>> _filteredList = new();
|
private readonly List<TreeViewItemData<Report.Entry>> _filteredList = new();
|
||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
{
|
{
|
||||||
var root = rootVisualElement;
|
var root = rootVisualElement;
|
||||||
|
|
@ -21,6 +27,15 @@ 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);
|
||||||
|
|
@ -61,11 +76,26 @@ namespace Module.ProjectValidator.Editor
|
||||||
|
|
||||||
_list.Clear();
|
_list.Clear();
|
||||||
|
|
||||||
for (var i = 0; i < Report.Active.Entries.Count; i++)
|
var entries = Report.Active.Entries;
|
||||||
|
var warningCount = 0;
|
||||||
|
var errorCount = 0;
|
||||||
|
|
||||||
|
for (var i = 0; i < entries.Count; i++)
|
||||||
{
|
{
|
||||||
_list.Add(new TreeViewItemData<Report.Entry>(i, Report.Active.Entries[i]));
|
_list.Add(new TreeViewItemData<Report.Entry>(i, 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,6 +154,8 @@ namespace Module.ProjectValidator.Editor
|
||||||
|
|
||||||
private void OnToolbarButtonClearClicked()
|
private void OnToolbarButtonClearClicked()
|
||||||
{
|
{
|
||||||
|
_groupWarnings.style.display = DisplayStyle.None;
|
||||||
|
_groupErrors.style.display = DisplayStyle.None;
|
||||||
ValidatorRunner.Clear();
|
ValidatorRunner.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,6 @@
|
||||||
-unity-font-style: bold;
|
-unity-font-style: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.toolbar-button-settings {
|
.toolbar-button-settings {
|
||||||
width: 24px;
|
width: 24px;
|
||||||
min-width: 24px;
|
min-width: 24px;
|
||||||
|
|
@ -30,3 +28,27 @@
|
||||||
-unity-background-scale-mode: scale-to-fit;
|
-unity-background-scale-mode: scale-to-fit;
|
||||||
margin-left: 0;
|
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,7 +2,16 @@
|
||||||
<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 style="flex-grow: 1;"/>
|
<uie:ToolbarSpacer name="spacing" 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:ToolbarButton text="" name="button-settings" class="toolbar-button-settings"/>
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
|
|
@ -17,4 +26,5 @@
|
||||||
</ui:Columns>
|
</ui:Columns>
|
||||||
<ui:SortColumnDescriptions/>
|
<ui:SortColumnDescriptions/>
|
||||||
</ui:MultiColumnTreeView>
|
</ui:MultiColumnTreeView>
|
||||||
|
<ui:Image/>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "com.module.project-validator",
|
"name": "com.module.project-validator",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"displayName": "Module.ProjectValidator",
|
"displayName": "Module.ProjectValidator",
|
||||||
"description": "",
|
"description": "",
|
||||||
"unity": "6000.3",
|
"unity": "6000.3",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue