Created
November 2, 2018 13:56
-
-
Save Bradshaw/7af1bf465a3b1f810d93b1700b3c562d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class FPS : MonoBehaviour { | |
Text text; | |
float smootheddt = 1 / 60; | |
float smoothvel; | |
List<float> last100; | |
// Use this for initialization | |
void Start () { | |
text = GetComponent<Text>(); | |
last100 = new List<float>(); | |
} | |
// Update is called once per frame | |
void Update () { | |
smootheddt = Mathf.SmoothDamp(smootheddt, Time.deltaTime, ref smoothvel, 1); | |
float fps = 1 / Time.deltaTime; | |
float sfps = 1 / smootheddt; | |
last100.Add(fps); | |
while (last100.Count>100) last100.RemoveAt(0); | |
float worst = last100[0]; | |
for (int i = 1; i < last100.Count; i++){ | |
worst = Mathf.Min(last100[i], worst); | |
} | |
text.text = "current:\t\t" + Mathf.Floor(fps * 100) / 100 + | |
"\naverage:\t" + Mathf.Floor(sfps * 100) / 100 + | |
"\nworst:\t\t" + Mathf.Floor(worst * 100) / 100; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Rotate : MonoBehaviour { | |
// Use this for initialization | |
void Start () { | |
} | |
// Update is called once per frame | |
void Update () { | |
transform.localRotation = | |
Quaternion.AngleAxis(90 * Time.deltaTime, Vector3.up) * transform.localRotation; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment