Skip to content

Commit

Permalink
FPS display
Browse files Browse the repository at this point in the history
  • Loading branch information
keijiro committed Oct 14, 2018
1 parent 3ff8c63 commit e7ac6db
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
81 changes: 81 additions & 0 deletions Assets/Main.unity
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_controllerUI: {fileID: 1604350981}
_fpsDisplay: {fileID: 519593614}
--- !u!4 &238417018
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1314,6 +1315,85 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 510009948}
m_CullTransparentMesh: 0
--- !u!1 &519593612
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 519593613}
- component: {fileID: 519593615}
- component: {fileID: 519593614}
m_Layer: 5
m_Name: FPS Display
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &519593613
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519593612}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1604350982}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -270, y: 20}
m_SizeDelta: {x: 500, y: 40}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &519593614
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519593612}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 12800000, guid: 33698d0f40a161548bafdd974b0dddf8, type: 3}
m_FontSize: 17
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 5
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 'FPS: 00.0'
--- !u!222 &519593615
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519593612}
m_CullTransparentMesh: 0
--- !u!1 &607339442
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -5953,6 +6033,7 @@ RectTransform:
- {fileID: 365648050}
- {fileID: 1628761040}
- {fileID: 2060222532}
- {fileID: 519593613}
m_Father: {fileID: 1919919253}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down
11 changes: 11 additions & 0 deletions Assets/Ngx/Script/AppController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace Ngx
sealed class AppController : MonoBehaviour
{
[SerializeField] GameObject _controllerUI = null;
[SerializeField] UnityEngine.UI.Text _fpsDisplay = null;

float _fpsCountStart = 0;

void Update()
{
Expand All @@ -13,6 +16,14 @@ void Update()
_controllerUI.SetActive(!_controllerUI.activeSelf);
Cursor.visible = !Cursor.visible;
}

if (Time.frameCount % 10 == 0)
{
var current = Time.time;
var fps = 10 / (current - _fpsCountStart);
_fpsDisplay.text = fps.ToString("FPS: 0.0");
_fpsCountStart = current;
}
}
}
}

0 comments on commit e7ac6db

Please sign in to comment.