summaryrefslogtreecommitdiff
path: root/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-08-20 23:40:50 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-08-20 23:40:50 -0400
commit3af4c218c0e70167db23a6303d2af30aff37d2fe (patch)
tree927f29edcf54ab562f40f3d1c6cb69287c7f5980 /Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps
parentb6daed0af784f4e9bc13329dd87c671b06ee1c65 (diff)
downloadProject-Sandbox-3af4c218c0e70167db23a6303d2af30aff37d2fe.tar.gz
Project-Sandbox-3af4c218c0e70167db23a6303d2af30aff37d2fe.tar.bz2
Project-Sandbox-3af4c218c0e70167db23a6303d2af30aff37d2fe.zip
Removed a bunch of stuff; Changes
Diffstat (limited to 'Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps')
-rw-r--r--Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsGraph.cs178
-rw-r--r--Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsGraph.cs.meta12
-rw-r--r--Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsManager.cs257
-rw-r--r--Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsManager.cs.meta12
-rw-r--r--Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsMonitor.cs178
-rw-r--r--Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsMonitor.cs.meta12
-rw-r--r--Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsText.cs170
-rw-r--r--Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsText.cs.meta12
8 files changed, 831 insertions, 0 deletions
diff --git a/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsGraph.cs b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsGraph.cs
new file mode 100644
index 0000000..6cc0d6a
--- /dev/null
+++ b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsGraph.cs
@@ -0,0 +1,178 @@
+/* ---------------------------------------
+ * Author: Martin Pane (martintayx@gmail.com) (@tayx94)
+ * Collaborators: Lars Aalbertsen (@Rockylars)
+ * Project: Graphy - Ultimate Stats Monitor
+ * Date: 15-Dec-17
+ * Studio: Tayx
+ *
+ * This project is released under the MIT license.
+ * Attribution is not required, but it is always welcomed!
+ * -------------------------------------*/
+
+using Tayx.Graphy.Graph;
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace Tayx.Graphy.Fps
+{
+ public class G_FpsGraph : G_Graph
+ {
+ /* ----- TODO: ----------------------------
+ * Add summaries to the variables.
+ * Add summaries to the functions.
+ * Check if we should add a "RequireComponent" for "FpsMonitor".
+ * --------------------------------------*/
+
+ #region Variables -> Serialized Private
+
+ [SerializeField] private Image m_imageGraph = null;
+
+ [SerializeField] private Shader ShaderFull = null;
+ [SerializeField] private Shader ShaderLight = null;
+
+ #endregion
+
+ #region Variables -> Private
+
+ private GraphyManager m_graphyManager = null;
+
+ private G_FpsMonitor m_fpsMonitor = null;
+
+ private int m_resolution = 150;
+
+ private G_GraphShader m_shaderGraph = null;
+
+ private int[] m_fpsArray;
+
+ private int m_highestFps;
+
+ #endregion
+
+ #region Methods -> Unity Callbacks
+
+ private void OnEnable()
+ {
+ Init();
+ }
+
+ private void Update()
+ {
+ UpdateGraph();
+ }
+
+ #endregion
+
+ #region Methods -> Public
+
+ public void UpdateParameters()
+ {
+ switch (m_graphyManager.GraphyMode)
+ {
+ case GraphyManager.Mode.FULL:
+ m_shaderGraph.ArrayMaxSize = G_GraphShader.ArrayMaxSizeFull;
+ m_shaderGraph.Image.material = new Material(ShaderFull);
+ break;
+
+ case GraphyManager.Mode.LIGHT:
+ m_shaderGraph.ArrayMaxSize = G_GraphShader.ArrayMaxSizeLight;
+ m_shaderGraph.Image.material = new Material(ShaderLight);
+ break;
+ }
+
+ m_shaderGraph.InitializeShader();
+
+ m_resolution = m_graphyManager.FpsGraphResolution;
+
+ CreatePoints();
+ }
+
+ #endregion
+
+ #region Methods -> Protected Override
+
+ protected override void UpdateGraph()
+ {
+ int fps = (int)(1 / Time.unscaledDeltaTime);
+
+ int currentMaxFps = 0;
+
+ for (int i = 0; i <= m_resolution - 1; i++)
+ {
+ if (i >= m_resolution - 1)
+ {
+ m_fpsArray[i] = fps;
+ }
+ else
+ {
+ m_fpsArray[i] = m_fpsArray[i + 1];
+ }
+
+ // Store the highest fps to use as the highest point in the graph
+
+ if (currentMaxFps < m_fpsArray[i])
+ {
+ currentMaxFps = m_fpsArray[i];
+ }
+
+ }
+
+ m_highestFps = m_highestFps < 1 || m_highestFps <= currentMaxFps ? currentMaxFps : m_highestFps - 1;
+
+ for (int i = 0; i <= m_resolution - 1; i++)
+ {
+ m_shaderGraph.Array[i] = m_fpsArray[i] / (float) m_highestFps;
+ }
+
+ // Update the material values
+
+ m_shaderGraph.UpdatePoints();
+
+ m_shaderGraph.Average = m_fpsMonitor.AverageFPS / m_highestFps;
+ m_shaderGraph.UpdateAverage();
+
+ m_shaderGraph.GoodThreshold = (float)m_graphyManager.GoodFPSThreshold / m_highestFps;
+ m_shaderGraph.CautionThreshold = (float)m_graphyManager.CautionFPSThreshold / m_highestFps;
+ m_shaderGraph.UpdateThresholds();
+ }
+
+ protected override void CreatePoints()
+ {
+ m_shaderGraph.Array = new float[m_resolution];
+
+ m_fpsArray = new int[m_resolution];
+
+ for (int i = 0; i < m_resolution; i++)
+ {
+ m_shaderGraph.Array[i] = 0;
+ }
+
+ m_shaderGraph.GoodColor = m_graphyManager.GoodFPSColor;
+ m_shaderGraph.CautionColor = m_graphyManager.CautionFPSColor;
+ m_shaderGraph.CriticalColor = m_graphyManager.CriticalFPSColor;
+
+ m_shaderGraph.UpdateColors();
+
+ m_shaderGraph.UpdateArray();
+ }
+
+ #endregion
+
+ #region Methods -> Private
+
+ private void Init()
+ {
+ m_graphyManager = transform.root.GetComponentInChildren<GraphyManager>();
+
+ m_fpsMonitor = GetComponent<G_FpsMonitor>();
+
+ m_shaderGraph = new G_GraphShader
+ {
+ Image = m_imageGraph
+ };
+
+ UpdateParameters();
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsGraph.cs.meta b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsGraph.cs.meta
new file mode 100644
index 0000000..66d52c8
--- /dev/null
+++ b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsGraph.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 2e119c7747ac400478c7cfcaea03214e
+timeCreated: 1511794194
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsManager.cs b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsManager.cs
new file mode 100644
index 0000000..ee3d172
--- /dev/null
+++ b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsManager.cs
@@ -0,0 +1,257 @@
+/* ---------------------------------------
+ * Author: Martin Pane (martintayx@gmail.com) (@tayx94)
+ * Collaborators: Lars Aalbertsen (@Rockylars)
+ * Project: Graphy - Ultimate Stats Monitor
+ * Date: 03-Jan-18
+ * Studio: Tayx
+ *
+ * This project is released under the MIT license.
+ * Attribution is not required, but it is always welcomed!
+ * -------------------------------------*/
+
+using UnityEngine;
+using System.Collections.Generic;
+using Tayx.Graphy.UI;
+using Tayx.Graphy.Utils;
+using UnityEngine.UI;
+
+namespace Tayx.Graphy.Fps
+{
+ public class G_FpsManager : MonoBehaviour, IMovable, IModifiableState
+ {
+ /* ----- TODO: ----------------------------
+ * Check if we can seal this class.
+ * Add summaries to the variables.
+ * Add summaries to the functions.
+ * Check if we should add a "RequireComponent" for "RectTransform".
+ * Check if we should add a "RequireComponent" for "FpsGraph".
+ * Check if we should add a "RequireComponent" for "FpsMonitor".
+ * Check if we should add a "RequireComponent" for "FpsText".
+ * --------------------------------------*/
+
+ #region Variables -> Serialized Private
+
+ [SerializeField] private GameObject m_fpsGraphGameObject = null;
+
+ [SerializeField] private List<GameObject> m_nonBasicTextGameObjects = new List<GameObject>();
+
+ [SerializeField] private List<Image> m_backgroundImages = new List<Image>();
+
+ #endregion
+
+ #region Variables -> Private
+
+ private GraphyManager m_graphyManager = null;
+
+ private G_FpsGraph m_fpsGraph = null;
+ private G_FpsMonitor m_fpsMonitor = null;
+ private G_FpsText m_fpsText = null;
+
+ private RectTransform m_rectTransform = null;
+
+ private List<GameObject> m_childrenGameObjects = new List<GameObject>();
+
+ private GraphyManager.ModuleState m_previousModuleState = GraphyManager.ModuleState.FULL;
+ private GraphyManager.ModuleState m_currentModuleState = GraphyManager.ModuleState.FULL;
+
+ #endregion
+
+ #region Methods -> Unity Callbacks
+
+ private void Awake()
+ {
+ Init();
+ }
+
+ private void Start()
+ {
+ UpdateParameters();
+ }
+
+ #endregion
+
+ #region Methods -> Public
+
+ public void SetPosition(GraphyManager.ModulePosition newModulePosition)
+ {
+ float xSideOffset = Mathf.Abs(m_rectTransform.anchoredPosition.x);
+ float ySideOffset = Mathf.Abs(m_rectTransform.anchoredPosition.y);
+
+ switch (newModulePosition)
+ {
+ case GraphyManager.ModulePosition.TOP_LEFT:
+
+ m_rectTransform.anchorMax = Vector2.up;
+ m_rectTransform.anchorMin = Vector2.up;
+ m_rectTransform.anchoredPosition = new Vector2(xSideOffset, -ySideOffset);
+
+ break;
+
+ case GraphyManager.ModulePosition.TOP_RIGHT:
+
+ m_rectTransform.anchorMax = Vector2.one;
+ m_rectTransform.anchorMin = Vector2.one;
+ m_rectTransform.anchoredPosition = new Vector2(-xSideOffset, -ySideOffset);
+
+ break;
+
+ case GraphyManager.ModulePosition.BOTTOM_LEFT:
+
+ m_rectTransform.anchorMax = Vector2.zero;
+ m_rectTransform.anchorMin = Vector2.zero;
+ m_rectTransform.anchoredPosition = new Vector2(xSideOffset, ySideOffset);
+
+ break;
+
+ case GraphyManager.ModulePosition.BOTTOM_RIGHT:
+
+ m_rectTransform.anchorMax = Vector2.right;
+ m_rectTransform.anchorMin = Vector2.right;
+ m_rectTransform.anchoredPosition = new Vector2(-xSideOffset, ySideOffset);
+
+ break;
+
+ case GraphyManager.ModulePosition.FREE:
+ break;
+ }
+ }
+
+ public void SetState(GraphyManager.ModuleState state, bool silentUpdate = false)
+ {
+ if (!silentUpdate)
+ {
+ m_previousModuleState = m_currentModuleState;
+ }
+
+ m_currentModuleState = state;
+
+ switch (state)
+ {
+ case GraphyManager.ModuleState.FULL:
+ gameObject.SetActive(true);
+ m_childrenGameObjects.SetAllActive(true);
+ SetGraphActive(true);
+
+ if (m_graphyManager.Background)
+ {
+ m_backgroundImages.SetOneActive(0);
+ }
+ else
+ {
+ m_backgroundImages.SetAllActive(false);
+ }
+
+ break;
+
+ case GraphyManager.ModuleState.TEXT:
+ gameObject.SetActive(true);
+ m_childrenGameObjects.SetAllActive(true);
+ SetGraphActive(false);
+
+ if (m_graphyManager.Background)
+ {
+ m_backgroundImages.SetOneActive(1);
+ }
+ else
+ {
+ m_backgroundImages.SetAllActive(false);
+ }
+
+ break;
+
+ case GraphyManager.ModuleState.BASIC:
+ gameObject.SetActive(true);
+ m_childrenGameObjects.SetAllActive(true);
+ m_nonBasicTextGameObjects.SetAllActive(false);
+ SetGraphActive(false);
+
+ if (m_graphyManager.Background)
+ {
+ m_backgroundImages.SetOneActive(2);
+ }
+ else
+ {
+ m_backgroundImages.SetAllActive(false);
+ }
+
+ break;
+
+ case GraphyManager.ModuleState.BACKGROUND:
+ gameObject.SetActive(true);
+ m_childrenGameObjects.SetAllActive(false);
+ SetGraphActive(false);
+
+ m_backgroundImages.SetAllActive(false);
+ break;
+
+ case GraphyManager.ModuleState.OFF:
+ gameObject.SetActive(false);
+ break;
+ }
+ }
+
+ public void RestorePreviousState()
+ {
+ SetState(m_previousModuleState);
+ }
+
+ public void UpdateParameters()
+ {
+ foreach (var image in m_backgroundImages)
+ {
+ image.color = m_graphyManager.BackgroundColor;
+ }
+
+ m_fpsGraph .UpdateParameters();
+ m_fpsMonitor .UpdateParameters();
+ m_fpsText .UpdateParameters();
+
+ SetState(m_graphyManager.FpsModuleState);
+ }
+
+ public void RefreshParameters()
+ {
+ foreach (var image in m_backgroundImages)
+ {
+ image.color = m_graphyManager.BackgroundColor;
+ }
+
+ m_fpsGraph .UpdateParameters();
+ m_fpsMonitor .UpdateParameters();
+ m_fpsText .UpdateParameters();
+
+ SetState(m_currentModuleState, true);
+ }
+
+ #endregion
+
+ #region Methods -> Private
+
+ private void Init()
+ {
+ m_graphyManager = transform.root.GetComponentInChildren<GraphyManager>();
+
+ m_rectTransform = GetComponent<RectTransform>();
+
+ m_fpsGraph = GetComponent<G_FpsGraph>();
+ m_fpsMonitor = GetComponent<G_FpsMonitor>();
+ m_fpsText = GetComponent<G_FpsText>();
+
+ foreach (Transform child in transform)
+ {
+ if (child.parent == transform)
+ {
+ m_childrenGameObjects.Add(child.gameObject);
+ }
+ }
+ }
+
+ private void SetGraphActive(bool active)
+ {
+ m_fpsGraph.enabled = active;
+ m_fpsGraphGameObject.SetActive(active);
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsManager.cs.meta b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsManager.cs.meta
new file mode 100644
index 0000000..588a34c
--- /dev/null
+++ b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsManager.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 221dc0b3655ddb749ace6bad55f0159f
+timeCreated: 1514998359
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsMonitor.cs b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsMonitor.cs
new file mode 100644
index 0000000..4aadfa8
--- /dev/null
+++ b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsMonitor.cs
@@ -0,0 +1,178 @@
+/* ---------------------------------------
+ * Author: Martin Pane (martintayx@gmail.com) (@tayx94)
+ * Collaborators: Lars Aalbertsen (@Rockylars)
+ * Project: Graphy - Ultimate Stats Monitor
+ * Date: 15-Dec-17
+ * Studio: Tayx
+ *
+ * This project is released under the MIT license.
+ * Attribution is not required, but it is always welcomed!
+ * -------------------------------------*/
+
+using UnityEngine;
+using System.Runtime.CompilerServices;
+
+namespace Tayx.Graphy.Fps
+{
+ public class G_FpsMonitor : MonoBehaviour
+ {
+ /* ----- TODO: ----------------------------
+ * Add summaries to the variables.
+ * Add summaries to the functions.
+ * --------------------------------------*/
+
+ #region Variables -> Serialized Private
+
+ [SerializeField] private int m_averageSamples = 200;
+
+ #endregion
+
+ #region Variables -> Private
+
+ private GraphyManager m_graphyManager;
+
+ private float m_currentFps = 0f;
+ private float m_avgFps = 0f;
+ private float m_minFps = 0f;
+ private float m_maxFps = 0f;
+
+ private float[] m_averageFpsSamples;
+ private int m_avgFpsSamplesOffset = 0;
+ private int m_indexMask = 0;
+ private int m_avgFpsSamplesCapacity = 0;
+ private int m_avgFpsSamplesCount = 0;
+ private int m_timeToResetMinMaxFps = 10;
+
+ private float m_timeToResetMinFpsPassed = 0f;
+ private float m_timeToResetMaxFpsPassed = 0f;
+
+ private float unscaledDeltaTime = 0f;
+
+ #endregion
+
+ #region Properties -> Public
+
+ public float CurrentFPS { get { return m_currentFps; } }
+ public float AverageFPS { get { return m_avgFps;} }
+
+ public float MinFPS { get { return m_minFps;} }
+ public float MaxFPS { get { return m_maxFps;} }
+
+ #endregion
+
+ #region Methods -> Unity Callbacks
+
+ private void Awake()
+ {
+ Init();
+ }
+
+ private void Update()
+ {
+ unscaledDeltaTime = Time.unscaledDeltaTime;
+
+ m_timeToResetMinFpsPassed += unscaledDeltaTime;
+ m_timeToResetMaxFpsPassed += unscaledDeltaTime;
+
+ // Update fps and ms
+
+ m_currentFps = 1 / unscaledDeltaTime;
+
+ // Update avg fps
+
+ m_avgFps = 0;
+
+ m_averageFpsSamples[ToBufferIndex(m_avgFpsSamplesCount)] = m_currentFps;
+ m_avgFpsSamplesOffset = ToBufferIndex(m_avgFpsSamplesOffset + 1);
+
+ if (m_avgFpsSamplesCount < m_avgFpsSamplesCapacity)
+ {
+ m_avgFpsSamplesCount++;
+ }
+
+ for (int i = 0; i < m_avgFpsSamplesCount; i++)
+ {
+ m_avgFps += m_averageFpsSamples[i];
+ }
+
+ m_avgFps /= m_avgFpsSamplesCount;
+
+ // Checks to reset min and max fps
+
+ if ( m_timeToResetMinMaxFps > 0
+ && m_timeToResetMinFpsPassed > m_timeToResetMinMaxFps)
+ {
+ m_minFps = 0;
+ m_timeToResetMinFpsPassed = 0;
+ }
+
+ if ( m_timeToResetMinMaxFps > 0
+ && m_timeToResetMaxFpsPassed > m_timeToResetMinMaxFps)
+ {
+ m_maxFps = 0;
+ m_timeToResetMaxFpsPassed = 0;
+ }
+
+ // Update min fps
+
+ if (m_currentFps < m_minFps || m_minFps <= 0)
+ {
+ m_minFps = m_currentFps;
+
+ m_timeToResetMinFpsPassed = 0;
+ }
+
+ // Update max fps
+
+ if (m_currentFps > m_maxFps || m_maxFps <= 0)
+ {
+ m_maxFps = m_currentFps;
+
+ m_timeToResetMaxFpsPassed = 0;
+ }
+ }
+
+ #endregion
+
+ #region Methods -> Public
+
+ public void UpdateParameters()
+ {
+ m_timeToResetMinMaxFps = m_graphyManager.TimeToResetMinMaxFps;
+ }
+
+ #endregion
+
+ #region Methods -> Private
+
+ private void Init()
+ {
+ m_graphyManager = transform.root.GetComponentInChildren<GraphyManager>();
+
+ ResizeSamplesBuffer(m_averageSamples);
+
+ UpdateParameters();
+ }
+
+
+ private void ResizeSamplesBuffer(int size)
+ {
+ m_avgFpsSamplesCapacity = Mathf.NextPowerOfTwo(size);
+
+ m_averageFpsSamples = new float[m_avgFpsSamplesCapacity];
+
+ m_indexMask = m_avgFpsSamplesCapacity - 1;
+ m_avgFpsSamplesOffset = 0;
+ }
+
+#if NET_4_6 || NET_STANDARD_2_0
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+#endif
+ private int ToBufferIndex(int index)
+ {
+ return (index + m_avgFpsSamplesOffset) & m_indexMask;
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsMonitor.cs.meta b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsMonitor.cs.meta
new file mode 100644
index 0000000..56e47db
--- /dev/null
+++ b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsMonitor.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: b205584e495e4634aa3a332a78102a19
+timeCreated: 1513376950
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsText.cs b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsText.cs
new file mode 100644
index 0000000..7ad691e
--- /dev/null
+++ b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsText.cs
@@ -0,0 +1,170 @@
+/* ---------------------------------------
+ * Author: Martin Pane (martintayx@gmail.com) (@tayx94)
+ * Collaborators: Lars Aalbertsen (@Rockylars)
+ * Project: Graphy - Ultimate Stats Monitor
+ * Date: 22-Nov-17
+ * Studio: Tayx
+ *
+ * This project is released under the MIT license.
+ * Attribution is not required, but it is always welcomed!
+ * -------------------------------------*/
+
+using UnityEngine;
+using UnityEngine.UI;
+using Tayx.Graphy.Utils.NumString;
+
+namespace Tayx.Graphy.Fps
+{
+ public class G_FpsText : MonoBehaviour
+ {
+ /* ----- TODO: ----------------------------
+ * Add summaries to the variables.
+ * Add summaries to the functions.
+ * Check if we should add a "RequireComponent" for "FpsMonitor".
+ * Improve the IntString Init to come from the core instead.
+ * --------------------------------------*/
+
+ #region Variables -> Serialized Private
+
+ [SerializeField] private Text m_fpsText = null;
+ [SerializeField] private Text m_msText = null;
+
+ [SerializeField] private Text m_avgFpsText = null;
+ [SerializeField] private Text m_minFpsText = null;
+ [SerializeField] private Text m_maxFpsText = null;
+
+ #endregion
+
+ #region Variables -> Private
+
+ private GraphyManager m_graphyManager = null;
+
+ private G_FpsMonitor m_fpsMonitor = null;
+
+ private int m_updateRate = 4; // 4 updates per sec.
+
+ private int m_frameCount = 0;
+
+ private float m_deltaTime = 0f;
+
+ private float m_fps = 0f;
+
+ private const int m_minFps = 0;
+ private const int m_maxFps = 10000;
+
+ private const string m_msStringFormat = "0.0";
+
+ #endregion
+
+ #region Methods -> Unity Callbacks
+
+ private void Awake()
+ {
+ Init();
+ }
+
+ private void Update()
+ {
+ m_deltaTime += Time.unscaledDeltaTime;
+
+ m_frameCount++;
+
+ // Only update texts 'm_updateRate' times per second
+
+ if (m_deltaTime > 1f / m_updateRate)
+ {
+ m_fps = m_frameCount / m_deltaTime;
+
+ // Update fps and ms
+
+ m_fpsText.text = Mathf.RoundToInt(m_fps).ToStringNonAlloc();
+ m_msText.text = (m_deltaTime / m_frameCount * 1000f).ToStringNonAlloc(m_msStringFormat);
+
+ // Update min fps
+
+ m_minFpsText.text = m_fpsMonitor.MinFPS.ToInt().ToStringNonAlloc();
+
+ SetFpsRelatedTextColor(m_minFpsText, m_fpsMonitor.MinFPS);
+
+ // Update max fps
+
+ m_maxFpsText.text = m_fpsMonitor.MaxFPS.ToInt().ToStringNonAlloc();
+
+ SetFpsRelatedTextColor(m_maxFpsText, m_fpsMonitor.MaxFPS);
+
+ // Update avg fps
+
+ m_avgFpsText.text = m_fpsMonitor.AverageFPS.ToInt().ToStringNonAlloc();
+
+ SetFpsRelatedTextColor(m_avgFpsText, m_fpsMonitor.AverageFPS);
+
+ // Reset variables
+
+ m_deltaTime = 0f;
+ m_frameCount = 0;
+ }
+ }
+
+ #endregion
+
+ #region Methods -> Public
+
+ public void UpdateParameters()
+ {
+ m_updateRate = m_graphyManager.FpsTextUpdateRate;
+ }
+
+ #endregion
+
+ #region Methods -> Private
+
+ /// <summary>
+ /// Assigns color to a text according to their fps numeric value and
+ /// the colors specified in the 3 categories (Good, Caution, Critical).
+ /// </summary>
+ ///
+ /// <param name="text">
+ /// UI Text component to change its color
+ /// </param>
+ ///
+ /// <param name="fps">
+ /// Numeric fps value
+ /// </param>
+ private void SetFpsRelatedTextColor(Text text, float fps)
+ {
+ if (fps > m_graphyManager.GoodFPSThreshold)
+ {
+ text.color = m_graphyManager.GoodFPSColor;
+ }
+ else if (fps > m_graphyManager.CautionFPSThreshold)
+ {
+ text.color = m_graphyManager.CautionFPSColor;
+ }
+ else
+ {
+ text.color = m_graphyManager.CriticalFPSColor;
+ }
+ }
+
+ private void Init()
+ {
+ //TODO: Replace this with one activated from the core and figure out the min value.
+ if (!G_IntString.Inited || G_IntString.MinValue > m_minFps || G_IntString.MaxValue < m_maxFps)
+ {
+ G_IntString.Init
+ (
+ minNegativeValue: m_minFps,
+ maxPositiveValue: m_maxFps
+ );
+ }
+
+ m_graphyManager = transform.root.GetComponentInChildren<GraphyManager>();
+
+ m_fpsMonitor = GetComponent<G_FpsMonitor>();
+
+ UpdateParameters();
+ }
+
+ #endregion
+ }
+}
diff --git a/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsText.cs.meta b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsText.cs.meta
new file mode 100644
index 0000000..41d6fcf
--- /dev/null
+++ b/Assets/Thirdparty/Tayx/Graphy - Ultimate Stats Monitor/Scripts/Fps/G_FpsText.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: f74bbf307d92b0d4e81ae60b9eb1e42f
+timeCreated: 1511555604
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: