文档

Unity Engine

Unity Engine

ValidateDefines(string[], out string)

Validates the given array of constant defines.
阅读时间1 分钟最后更新于 1 个月前

Definition

ValidateDefines(string[], string)

public static bool ValidateDefines(string[] defines, out string msg)

Parameters

defines

The constant define array to validate.

The error message if validation errors occur.

Returns

Type

Description

boolTrue if the constant define data is valid, otherwise false.

Remarks

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.

Examples

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); } }}