Profiling.Sampler.isValid

Unity · Версия 2020.3 LTS · Scripting · Sampler

Profiling.Sampler.isValid

public bool isValid;

Описание

Возвращает true, если сэмплер действителен. (Только чтение). Invalid Sampler представляет несуществующую метку Profiler.

Примечание. В настоящий момент все встроенные счетчики доступны только в редакторе и проигрывателях разработки. Sampler.Get в неразрабатываемых проигрывателях возвращает недопустимый сэмплер.

using UnityEngine;
using UnityEngine.Profiling;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Start()
    {
        var sampler = Sampler.Get("BehaviourUpdate");
        if (sampler.isValid)
            Debug.Log("Retrieved a Sampler for BehaviourUpdate!");

        sampler = Sampler.Get("TerrainRenderer");
        if (!sampler.isValid)
            Debug.Log("Profiler label TerrainRenderer does not exist!");
    }
}

Обновлено 17 ноября 2026 г.