Unity Tips
Jul 25, 2026 · 1 min read · dmg dekels
Custom Profiling Blocks with Profiler.BeginSample
Locating specific code bottlenecks in Unity’s Profiler can be tricky when logic is grouped inside standard engine blocks.
The Tip: Locating specific code bottlenecks in Unity’s Profiler can be tricky when logic is grouped inside standard engine blocks.
How to Use: Wrap suspicious logic in Profiler.BeginSample("Sample Name") and Profiler.EndSample(). Your custom sample will appear directly within the Profiler hierarchy view.
using UnityEngine;
using UnityEngine.Profiling;
public class CustomProfilerMarker : MonoBehaviour
{
private void Update()
{
Profiler.BeginSample("Custom Pathfinding Search");
// Pathfinding calculation logic
Profiler.EndSample();
}
}Article complete
XP lands automatically when you reach the end.
Rate this article
Comments
Comments are held for moderation before appearing publicly.