Added GameObject Validators
This commit is contained in:
parent
c8a6815316
commit
269789b36f
15 changed files with 160 additions and 13 deletions
|
|
@ -0,0 +1,22 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.ProjectValidator.Editor
|
||||
{
|
||||
internal sealed class ComponentValidatorSkinnedMeshRenderer : IComponentValidator<SkinnedMeshRenderer>
|
||||
{
|
||||
public void Validate(SkinnedMeshRenderer component, List<ValidatorResult> results)
|
||||
{
|
||||
var materials = component.sharedMaterials;
|
||||
|
||||
for (var i = 0; i < materials.Length; i++)
|
||||
{
|
||||
if (materials[i] == null)
|
||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Error, $"Missing material in slot #{i}"));
|
||||
}
|
||||
|
||||
if (component.sharedMesh == null)
|
||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Error, "Missing mesh"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1610561c53a0aa84aaa903e5dde29694
|
||||
3
Editor/Validators/GameObject.meta
Normal file
3
Editor/Validators/GameObject.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 45fa253dcfa349d5b1e9bd56ebac7c98
|
||||
timeCreated: 1779133809
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.ProjectValidator.Editor
|
||||
{
|
||||
internal sealed class GameObjectValidatorBrokenPrefab : IGameObjectValidator
|
||||
{
|
||||
public void Validate(GameObject gameObject, List<ValidatorResult> results)
|
||||
{
|
||||
if (PrefabUtility.IsPrefabAssetMissing(gameObject))
|
||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Error, "GameObject is missing prefab asset"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8fd1dfcd3d564622a918e2175499318d
|
||||
timeCreated: 1779133864
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.ProjectValidator.Editor
|
||||
{
|
||||
internal sealed class GameObjectValidatorMissingComponents : IGameObjectValidator
|
||||
{
|
||||
public void Validate(GameObject gameObject, List<ValidatorResult> results)
|
||||
{
|
||||
var count = GameObjectUtility.GetMonoBehavioursWithMissingScriptCount(gameObject);
|
||||
|
||||
if (count != 0)
|
||||
results.Add(ValidatorResult.Create(EValidatorSeverity.Error, $"GameObject is missing {count} component(s)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 66cbc43729ec4e81a9e353e537b3ccf0
|
||||
timeCreated: 1779133947
|
||||
Loading…
Add table
Add a link
Reference in a new issue