Validator: Skipping textures in material, if marked as PerRendererData, HideInInspector or NonModifiableTextureData Validator: Fixed issue, where arrays weren't iterated correctly, which resulted in an exception Window: Added warning and error count
34 lines
No EOL
1.2 KiB
C#
34 lines
No EOL
1.2 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
|
|
namespace Module.ProjectValidator.Editor
|
|
{
|
|
internal sealed class AssetValidatorMaterialTexture : IAssetValidator<Material>
|
|
{
|
|
public void Validate(Material obj, List<ValidatorResult> results)
|
|
{
|
|
if (obj.shader == null)
|
|
return;
|
|
|
|
var count = obj.shader.GetPropertyCount();
|
|
|
|
for (var i = 0; i < count; i++)
|
|
{
|
|
var propertyType = obj.shader.GetPropertyType(i);
|
|
var propertyFlags = obj.shader.GetPropertyFlags(i);
|
|
|
|
if (propertyType != ShaderPropertyType.Texture)
|
|
continue;
|
|
if ((propertyFlags & (ShaderPropertyFlags.PerRendererData | ShaderPropertyFlags.HideInInspector | ShaderPropertyFlags.NonModifiableTextureData)) != 0)
|
|
continue;
|
|
|
|
var propertyName = obj.shader.GetPropertyName(i);
|
|
var propertyValue = obj.GetTexture(propertyName);
|
|
|
|
if (propertyValue == null)
|
|
results.Add(ValidatorResult.Create(EValidatorSeverity.Warning, $"Texture property '{propertyName}' is Null"));
|
|
}
|
|
}
|
|
}
|
|
} |