Version: 2018.2
public bool isValid ;

Description

Returns true if Sampler is valid. (Read Only)

Invalid Sampler represents non-existing Profiler label.

Note: At the moment all built-in counters are available only in the Editor and Development Players. Sampler.Get in non-Development Players returns invalid Sampler.

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!"); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961