Skip to content

Commit 90fd481

Browse files
author
David Kline (ANALOG)
committed
update diagnostic defaults, add frame rate duration
1 parent ad2cfda commit 90fd481

File tree

7 files changed

+69
-6
lines changed

7 files changed

+69
-6
lines changed

Assets/MixedRealityToolkit.SDK/Profiles/DefaultMixedRealityDiagnosticsProfile.asset

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ MonoBehaviour:
1313
m_Name: DefaultMixedRealityDiagnosticsProfile
1414
m_EditorClassIdentifier:
1515
isCustomProfile: 0
16-
showDiagnostics: 0
16+
showDiagnostics: 1
1717
showProfiler: 1
18+
frameRateDuration: 0.1

Assets/MixedRealityToolkit.Services/DiagnosticsSystem/MixedRealityDiagnosticsSystem.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,31 @@ public bool ShowProfiler
119119
}
120120
}
121121

122+
private float frameRateDuration = 0.1f;
123+
private readonly float minFrameRateDuration = 0.01f;
124+
private readonly float maxFrameRateDuration = 1.0f;
125+
126+
/// <inheritdoc />
127+
public float FrameRateDuration
128+
{
129+
get
130+
{
131+
return frameRateDuration;
132+
}
133+
134+
set
135+
{
136+
if (!Mathf.Approximately(frameRateDuration, value))
137+
{
138+
frameRateDuration = Mathf.Clamp(value, minFrameRateDuration, maxFrameRateDuration);
139+
if (visualProfiler != null)
140+
{
141+
visualProfiler.FrameSampleRate = frameRateDuration;
142+
}
143+
}
144+
}
145+
}
146+
122147
#endregion IMixedRealityDiagnosticsSystem
123148

124149
#region IMixedRealityEventSource

Assets/MixedRealityToolkit.Services/DiagnosticsSystem/MixedRealityToolkitVisualProfiler.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ public bool IsVisible
4242
[Range(0.0f, 1.0f)]
4343
private float frameSampleRate = 0.1f;
4444

45+
public float FrameSampleRate
46+
{
47+
get { return frameSampleRate; }
48+
set { frameSampleRate = Mathf.Clamp(value, 0.0f, 1.0f); }
49+
}
50+
4551
[Header("UI Settings")]
4652
[SerializeField]
4753
[Range(0.0f, 100.0f)]

Assets/MixedRealityToolkit/Definitions/Diagnostics/MixedRealityDiagnosticsProfile.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,30 @@ public class MixedRealityDiagnosticsProfile : BaseMixedRealityProfile
1616
[SerializeField]
1717
[FormerlySerializedAs("visible")]
1818
[Tooltip("Display all enabled diagnostics")]
19-
private bool showDiagnostics = false;
19+
private bool showDiagnostics = true;
2020

2121
/// <summary>
22-
/// Show or hide diagnostic visualizations
22+
/// Show or hide diagnostic visualizations.
2323
/// </summary>
2424
public bool ShowDiagnostics => showDiagnostics;
2525

2626
[SerializeField]
2727
[Tooltip("Display profiler")]
28-
private bool showProfiler = false;
28+
private bool showProfiler = true;
2929

3030
/// <summary>
31-
/// Show or hide the profiler UI
31+
/// Show or hide the profiler UI.
3232
/// </summary>
3333
public bool ShowProfiler => showProfiler;
34+
35+
[SerializeField]
36+
[Tooltip("The amount of time, in seconds, to collect frames for frame rate calculation.")]
37+
[Range(0.01f, 1.0f)]
38+
private float frameRateDuration = 0.1f;
39+
40+
/// <summary>
41+
/// The amount of time, in seconds, to collect frames for frame rate calculation.
42+
/// </summary>
43+
public float FrameRateDuration => frameRateDuration;
3444
}
3545
}

Assets/MixedRealityToolkit/Inspectors/Profiles/MixedRealityDiagnosticsSystemProfileInspector.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ public class MixedRealityDiagnosticsSystemProfileInspector : BaseMixedRealityToo
1414
{
1515
private static bool showGeneralSettings = true;
1616
private SerializedProperty showDiagnostics;
17+
18+
private static bool showProfilerSettings = true;
1719
private SerializedProperty showProfiler;
20+
private SerializedProperty frameRateDuration;
21+
1822
// todo: coming soon
23+
// private static bool showDebugPanelSettings = true;
1924
// private SerializedProperty isDebugPanelVisible;
2025

2126
protected override void OnEnable()
@@ -29,6 +34,7 @@ protected override void OnEnable()
2934

3035
showDiagnostics = serializedObject.FindProperty("showDiagnostics");
3136
showProfiler = serializedObject.FindProperty("showProfiler");
37+
frameRateDuration = serializedObject.FindProperty("frameRateDuration");
3238
}
3339

3440
public override void OnInspectorGUI()
@@ -65,8 +71,17 @@ public override void OnInspectorGUI()
6571
EditorGUILayout.HelpBox("Diagnostic visualizations have been globally disabled.", MessageType.Info);
6672
EditorGUILayout.Space();
6773
}
74+
}
75+
}
6876

77+
EditorGUILayout.Space();
78+
showProfilerSettings = EditorGUILayout.Foldout(showProfilerSettings, "Profiler Settings", true);
79+
if (showProfilerSettings)
80+
{
81+
using (new EditorGUI.IndentLevelScope())
82+
{
6983
EditorGUILayout.PropertyField(showProfiler);
84+
EditorGUILayout.PropertyField(frameRateDuration);
7085
}
7186
}
7287

Assets/MixedRealityToolkit/Inspectors/Profiles/MixedRealityToolkitConfigurationProfileInspector.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ public override void OnInspectorGUI()
285285
{
286286
using (new EditorGUI.IndentLevelScope())
287287
{
288+
EditorGUILayout.HelpBox("It is recommended to enable the Diagnostics system during development. Be sure to disable prior to building your shipping product.", MessageType.Warning);
288289
EditorGUILayout.PropertyField(enableDiagnosticsSystem);
289290
EditorGUILayout.PropertyField(diagnosticsSystemType);
290291
changed |= RenderProfile(diagnosticsSystemProfile);

Assets/MixedRealityToolkit/Interfaces/Diagnostics/IMixedRealityDiagnosticsSystem.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ public interface IMixedRealityDiagnosticsSystem : IMixedRealityEventSystem, IMix
2222
bool ShowDiagnostics { get; set; }
2323

2424
/// <summary>
25-
/// Enable / disable the profiler display
25+
/// Enable / disable the profiler display.
2626
/// </summary>
2727
bool ShowProfiler { get; set; }
28+
29+
/// <summary>
30+
/// The amount of time, in seconds, to collect frames for frame rate calculation.
31+
/// </summary>
32+
float FrameRateDuration { get; }
2833
}
2934
}

0 commit comments

Comments
 (0)