Created
December 1, 2016 15:39
-
-
Save v01pe/b6e5f33bd6f64deeb75204b4656d0d59 to your computer and use it in GitHub Desktop.
In Unity add a menu item that toggles between dynamic and the default profiler sample size.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
[InitializeOnLoad] | |
public static class DebugMenu | |
{ | |
private static int defaultMaxNumberOfSamplesPerFrame = -1; | |
private static bool dynamicProfilerSamplesSize = false; | |
private const string toggleDynamicProfilerSamplesSizeName = "Debug/Dynamic Profiler Sample Size"; | |
static DebugMenu() | |
{ | |
if (defaultMaxNumberOfSamplesPerFrame == -1) | |
defaultMaxNumberOfSamplesPerFrame = Profiler.maxNumberOfSamplesPerFrame; | |
} | |
[MenuItem(toggleDynamicProfilerSamplesSizeName)] | |
public static void ToggleDynamicProfilerSamplesSize() | |
{ | |
dynamicProfilerSamplesSize = !dynamicProfilerSamplesSize; | |
Menu.SetChecked(toggleDynamicProfilerSamplesSizeName, dynamicProfilerSamplesSize); | |
Profiler.maxNumberOfSamplesPerFrame = dynamicProfilerSamplesSize ? -1 : defaultMaxNumberOfSamplesPerFrame; | |
if (dynamicProfilerSamplesSize) | |
Debug.LogWarning("Profiler sample size is set to dynamic"); | |
else | |
Debug.Log("Profiler sample size has been set back to " + defaultMaxNumberOfSamplesPerFrame); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Drop this file in a folder called
Editor
within yourAssets
folder. You'll find the new item in the menu atDebug -> Dynamic Profiler Sample Size