docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct ProfilerMarker<TP1, TP2, TP3>

    Use ProfilerMarker<TP1> to mark up script code blocks for the Unity Profiler.

    You can pass three integral or floating point parameters alongside the Begin event. The following types are supported as parameters:

    • int
    • uint
    • long
    • ulong
    • float
    • double
    Namespace: Unity.Profiling
    Assembly: Unity.Profiling.Core.dll
    Syntax
    public readonly struct ProfilerMarker<TP1, TP2, TP3> where TP1 : unmanaged where TP2 : unmanaged where TP3 : unmanaged
    Type Parameters
    Name Description
    TP1

    Type of the first parameter.

    TP2

    Type of the second parameter.

    TP3

    Type of the third parameter.

    Constructors

    ProfilerMarker(string, string, string, string)

    Constructs a ProfilerMarker that belongs to the generic ProfilerCategory.Scripts category.

    Declaration
    public ProfilerMarker(string name, string param1Name, string param2Name, string param3Name)
    Parameters
    Type Name Description
    string name

    Name of a marker.

    string param1Name

    Name of the first parameter.

    string param2Name

    Name of the second parameter.

    string param3Name

    Name of the third parameter.

    Remarks

    Does nothing in Release Players.

    ProfilerMarker(ProfilerCategory, string, string, string, string)

    Constructs a ProfilerMarker.

    Declaration
    public ProfilerMarker(ProfilerCategory category, string name, string param1Name, string param2Name, string param3Name)
    Parameters
    Type Name Description
    ProfilerCategory category

    Profiler category.

    string name

    Name of a marker.

    string param1Name

    Name of the first parameter.

    string param2Name

    Name of the second parameter.

    string param3Name

    Name of the third parameter.

    Remarks

    Does nothing in Release Players.

    Methods

    Auto(TP1, TP2, TP3)

    Use to profile a piece of code enclosed within using statement.

    Declaration
    public ProfilerMarker<TP1, TP2, TP3>.AutoScope Auto(TP1 p1, TP2 p2, TP3 p3)
    Parameters
    Type Name Description
    TP1 p1

    The first context parameter.

    TP2 p2

    The second context parameter.

    TP3 p3

    The third context parameter.

    Returns
    Type Description
    ProfilerMarker<TP1, TP2, TP3>.AutoScope

    IDisposable struct which calls End on Dispose.

    Remarks

    Returns null in Release Players.

    Examples
    using (profilerMarker.Auto(enemies.Count, blastRadius, blastPos.x))
    {
        var blastRadius2 = blastRadius * blastRadius;
        for (int i = 0; i < enemies.Count; ++i)
        {
            var r2 = (enemies[i].Pos - blastPos).sqrMagnitude;
            if (r2 < blastRadius2)
                enemies[i].Dispose();
        }
    }

    Begin(TP1, TP2, TP3)

    Begin profiling a piece of code marked with the ProfilerMarker instance.

    Declaration
    [Conditional("ENABLE_PROFILER")]
    [Pure]
    public void Begin(TP1 p1, TP2 p2, TP3 p3)
    Parameters
    Type Name Description
    TP1 p1

    The first context parameter.

    TP2 p2

    The second context parameter.

    TP3 p3

    The third context parameter.

    Remarks

    Does nothing in Release Players.

    End()

    End profiling a piece of code marked with the ProfilerMarker instance.

    Declaration
    [Conditional("ENABLE_PROFILER")]
    [Pure]
    public void End()
    Remarks

    Does nothing in Release Players.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)