Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

GraphicsApiValidation.IsValidationActive

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static bool IsValidationActive();

Returns

bool true if validation is active; otherwise false.

Description

Returns whether graphics API validation is active and the debug layer initialized successfully.

This returns true only if you requested validation (see GraphicsApiValidation.IsValidationRequested) and the debug layer successfully attached during device creation. Use this as the canonical gate before calling other GraphicsApiValidation members, since on platforms or runs where validation isn't active the other members have no effect.

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;

public class Example : MonoBehaviour { // Returns null when validation isn't active so callers can skip // reporting on platforms or runs where errors can't be collected. IReadOnlyList<string> CollectValidationErrors() { if (!GraphicsApiValidation.IsValidationActive()) return null;

int count = GraphicsApiValidation.GetValidationErrorCount(); var errors = new List<string>(count); for (int i = 0; i < count; i++) { errors.Add(GraphicsApiValidation.GetValidationError(i)); } return errors; } }