Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ProfilerScope as a public API #478

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#472] [#474] Added the `DependsOnContext` attribute, for declaring dependencies between extension contexts.
- [#473] Added `BuildContext.SetEnableUVDistributionRecalculation` to allow opting out from the automatic call to
`Mesh.RecalculateUVDistributionMetrics` on generated meshes.
- [#478] Added `ProfilerScope` API

### Fixed

Expand Down
15 changes: 11 additions & 4 deletions Editor/ProfilerScope.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
using System;
#nullable enable

using System;
using JetBrains.Annotations;
using UnityEngine.Profiling;

namespace nadena.dev.ndmf
{
internal struct ProfilerScope : IDisposable
/// <summary>
/// Performs a `Profiler.BeginSample` call on construction, and `Profiler.EndSample` on disposal.
/// </summary>
[PublicAPI]
public struct ProfilerScope : IDisposable
{
public ProfilerScope(string name)
public ProfilerScope(string name, UnityEngine.Object? target = null)
{
Profiler.BeginSample(name);
Profiler.BeginSample(name, target);
}

public void Dispose()
Expand Down