init
This commit is contained in:
37
Assets/Mirror/Examples/Common/FPS.cs
Normal file
37
Assets/Mirror/Examples/Common/FPS.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirror.Examples.Cubes
|
||||
{
|
||||
public class FPS : MonoBehaviour
|
||||
{
|
||||
// fps accessible to the outside
|
||||
public int framesPerSecond { get; private set; }
|
||||
|
||||
// configuration
|
||||
public bool showGUI = true;
|
||||
public bool showLog = false;
|
||||
|
||||
// helpers
|
||||
int count;
|
||||
double startTime;
|
||||
|
||||
protected void Update()
|
||||
{
|
||||
++count;
|
||||
if (Time.time >= startTime + 1)
|
||||
{
|
||||
framesPerSecond = count;
|
||||
startTime = Time.time;
|
||||
count = 0;
|
||||
if (showLog) Debug.Log($"FPS: {framesPerSecond}");
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnGUI()
|
||||
{
|
||||
if (!showGUI) return;
|
||||
|
||||
GUI.Label(new Rect(Screen.width - 70, 0, 70, 25), $"FPS: {framesPerSecond}");
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Mirror/Examples/Common/FPS.cs.meta
Normal file
11
Assets/Mirror/Examples/Common/FPS.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6635375fbc6be456ea640b75add6378e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user