Skip to content

Commit 60ada7d

Browse files
Merge pull request #568 from StephenHodgson/HTK-local
FPS Display compatability with uGUI
2 parents f2ea49c + 3b41cc1 commit 60ada7d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Assets/HoloToolkit/Utilities/Scripts/FpsDisplay.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using UnityEngine;
5+
using UnityEngine.UI;
56

67
namespace HoloToolkit.Unity
78
{
@@ -11,10 +12,14 @@ namespace HoloToolkit.Unity
1112
[RequireComponent(typeof(TextMesh))]
1213
public class FpsDisplay : MonoBehaviour
1314
{
14-
[Tooltip("Reference to Text UI control where the FPS should be displayed.")]
15+
[Tooltip("Reference to TextMesh component where the FPS should be displayed.")]
1516
[SerializeField]
1617
private TextMesh textMesh;
1718

19+
[Tooltip("Reference to uGUI text component where the FPS should be displayed.")]
20+
[SerializeField]
21+
private Text uGUIText;
22+
1823
[Tooltip("How many frames should we consider into our average calculation?")]
1924
[SerializeField]
2025
private int frameRange = 60;
@@ -53,7 +58,15 @@ private void Update()
5358

5459
private void InitBuffer()
5560
{
56-
textMesh = GetComponent<TextMesh>();
61+
if (textMesh == null)
62+
{
63+
textMesh = GetComponent<TextMesh>();
64+
}
65+
66+
if (uGUIText == null)
67+
{
68+
uGUIText = GetComponent<Text>();
69+
}
5770

5871
if (frameRange <= 0)
5972
{
@@ -72,6 +85,11 @@ private void UpdateTextDisplay(int fps)
7285
{
7386
textMesh.text = displayString;
7487
}
88+
89+
if (uGUIText != null)
90+
{
91+
uGUIText.text = displayString;
92+
}
7593
}
7694

7795
private void UpdateFrameBuffer()

0 commit comments

Comments
 (0)