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

FpsDisplay fixes #382

Merged
merged 2 commits into from
Dec 9, 2016
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
42 changes: 23 additions & 19 deletions Assets/HoloToolkit/Utilities/Prefabs/FPSDisplay.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
serializedVersion: 5
m_Component:
- 4: {fileID: 4000012084356042}
- 23: {fileID: 23000012140561766}
- 102: {fileID: 102000012390400920}
- 114: {fileID: 114000014126132184}
- component: {fileID: 4000012084356042}
- component: {fileID: 23000012140561766}
- component: {fileID: 102000012390400920}
- component: {fileID: 114000014126132184}
m_Layer: 0
m_Name: FPSText
m_TagString: Untagged
Expand All @@ -34,14 +34,14 @@ GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
serializedVersion: 5
m_Component:
- 4: {fileID: 4000012520274942}
- 65: {fileID: 65000012561365858}
- 114: {fileID: 114000013985069792}
- 114: {fileID: 114000012205069828}
- 114: {fileID: 114000014245746336}
- 23: {fileID: 23000011797597042}
- component: {fileID: 4000012520274942}
- component: {fileID: 65000012561365858}
- component: {fileID: 114000013985069792}
- component: {fileID: 114000012205069828}
- component: {fileID: 114000014245746336}
- component: {fileID: 23000011797597042}
m_Layer: 0
m_Name: FPSDisplay
m_TagString: Untagged
Expand All @@ -58,10 +58,10 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.11, z: 0}
m_LocalScale: {x: 0.01, y: 0.01, z: 0.01}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 4000012520274942}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4000012520274942
Transform:
m_ObjectHideFlags: 1
Expand All @@ -71,11 +71,11 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0.85}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 4000012084356042}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &23000011797597042
MeshRenderer:
m_ObjectHideFlags: 1
Expand All @@ -90,15 +90,17 @@ MeshRenderer:
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0}
m_SubsetIndices:
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedWireframeHidden: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
Expand All @@ -119,15 +121,17 @@ MeshRenderer:
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0}
m_SubsetIndices:
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedWireframeHidden: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
Expand Down Expand Up @@ -226,4 +230,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ac8d5b128a1d8204fb76c86f47b75912, type: 3}
m_Name:
m_EditorClassIdentifier:
PivotAxis: 2
PivotAxis: 1
16 changes: 4 additions & 12 deletions Assets/HoloToolkit/Utilities/Scripts/FpsDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public class FpsDisplay : MonoBehaviour
[SerializeField]
private TextMesh textMesh;

[Tooltip("Reference to 3DText UI control where the FPS should be displayed.")]
[SerializeField]
private TextMesh text3D;

[Tooltip("How many frames should we consider into our average calculation?")]
[SerializeField]
private int frameRange = 60;
Expand Down Expand Up @@ -59,7 +55,7 @@ private void InitBuffer()
{
textMesh = GetComponent<TextMesh>();

if(frameRange <= 0)
if (frameRange <= 0)
{
frameRange = 1;
}
Expand All @@ -76,17 +72,13 @@ private void UpdateTextDisplay(int fps)
{
textMesh.text = displayString;
}
if (text3D != null)
{
text3D.text = displayString;
}
}

private void UpdateFrameBuffer()
{
fpsBuffer[fpsBufferIndex++] = (int)(1f/Time.unscaledDeltaTime);
fpsBuffer[fpsBufferIndex++] = (int)(1f / Time.unscaledDeltaTime);

if(fpsBufferIndex >= frameRange)
if (fpsBufferIndex >= frameRange)
{
fpsBufferIndex = 0;
}
Expand All @@ -96,7 +88,7 @@ private void CalculateFps()
{
int sum = 0;

for(int i = 0; i < frameRange; i++)
for (int i = 0; i < frameRange; i++)
{
int fps = fpsBuffer[i];
sum += fps;
Expand Down