public bool isValid ;

描述

如果采样器有效,则返回 true。(只读)

无效的采样器表示不存在的性能分析器标签。

注意:目前,所有内置计数器仅在 Editor 和 Development Player 中可用。非 Development Player 中的 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!"); } }