Version: 2017.1
public static Profiling.CustomSampler Create (string name);

参数

name 采样器的名称。

返回

CustomSampler CustomSampler 对象,如果存在具有相同名称的内置采样器,则返回 null

描述

创建一个用于分析代码的各个部分的新 CustomSampler。

Multiple calls with the same name parameter return different CustomSampler objects which refer to the same native representation.

Method throws ArgumentNullException when used with null string and ArgumentException when used with existing built-in Profiler label.

using UnityEngine;
using UnityEngine.Profiling;

public class ExampleClass : MonoBehaviour { CustomSampler sampler; void Start() { sampler = CustomSampler.Create("MyCustomSampler"); }

void Update() { sampler.Begin(); // do something that takes a lot of time sampler.End(); } }

另请参阅:CustomSampler.BeginSampler.Get