| Parameter | Description |
|---|---|
| defines | The constant define array to validate. |
| msg | The error message if validation errors occur. |
bool True if the constant define data is valid, otherwise false.
Validates the given array of constant defines.
This method checks that the define array does not contain multiple entries with the same identifier. It also runs data validation on each element individually.
using UnityEditor.Shaders;
using UnityEngine;
public class DefineValidationExample
{
void ValidateDefines()
{
string[] defineArray = new string[] { "MAX_NUM_LIGHTS 8", "EPSILON 0.1f" };
// Check if the define array is valid. This will catch both duplicates and invalid individual defines.
string validationErrors;
if (!ShaderBuildSettings.ValidateDefines(defineArray, out validationErrors))
{
Debug.LogWarning(validationErrors);
}
}
}