The fucking 3rd time i had to upload this project to git
This commit is contained in:
@ -0,0 +1,262 @@
|
||||
/* ---------------------------------------
|
||||
* Author: Martin Pane (martintayx@gmail.com) (@tayx94)
|
||||
* Contributors: https://github.com/Tayx94/graphy/graphs/contributors
|
||||
* Project: Graphy - Ultimate Stats Monitor
|
||||
* Date: 15-Dec-17
|
||||
* Studio: Tayx
|
||||
*
|
||||
* Git repo: https://github.com/Tayx94/graphy
|
||||
*
|
||||
* 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;
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
#endif
|
||||
|
||||
namespace Tayx.Graphy.Ram
|
||||
{
|
||||
public class G_RamGraph : G_Graph
|
||||
{
|
||||
#region Methods -> Unity Callbacks
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateGraph();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods -> Public
|
||||
|
||||
public void UpdateParameters()
|
||||
{
|
||||
if (m_shaderGraphAllocated == null
|
||||
|| m_shaderGraphReserved == null
|
||||
|| m_shaderGraphMono == null)
|
||||
/*
|
||||
* Note: this is fine, since we don't much
|
||||
* care what granularity we use if the graph
|
||||
* has not been initialized, i.e. it's disabled.
|
||||
* There is no chance that for some reason
|
||||
* parameters will not stay up to date if
|
||||
* at some point in the future the graph is enabled:
|
||||
* at the end of Init(), UpdateParameters() is
|
||||
* called again.
|
||||
*/
|
||||
return;
|
||||
|
||||
switch (m_graphyManager.GraphyMode)
|
||||
{
|
||||
case GraphyManager.Mode.FULL:
|
||||
m_shaderGraphAllocated.ArrayMaxSize = G_GraphShader.ArrayMaxSizeFull;
|
||||
m_shaderGraphReserved.ArrayMaxSize = G_GraphShader.ArrayMaxSizeFull;
|
||||
m_shaderGraphMono.ArrayMaxSize = G_GraphShader.ArrayMaxSizeFull;
|
||||
|
||||
m_shaderGraphAllocated.Image.material = new Material(ShaderFull);
|
||||
m_shaderGraphReserved.Image.material = new Material(ShaderFull);
|
||||
m_shaderGraphMono.Image.material = new Material(ShaderFull);
|
||||
break;
|
||||
|
||||
case GraphyManager.Mode.LIGHT:
|
||||
m_shaderGraphAllocated.ArrayMaxSize = G_GraphShader.ArrayMaxSizeLight;
|
||||
m_shaderGraphReserved.ArrayMaxSize = G_GraphShader.ArrayMaxSizeLight;
|
||||
m_shaderGraphMono.ArrayMaxSize = G_GraphShader.ArrayMaxSizeLight;
|
||||
|
||||
m_shaderGraphAllocated.Image.material = new Material(ShaderLight);
|
||||
m_shaderGraphReserved.Image.material = new Material(ShaderLight);
|
||||
m_shaderGraphMono.Image.material = new Material(ShaderLight);
|
||||
break;
|
||||
}
|
||||
|
||||
m_shaderGraphAllocated.InitializeShader();
|
||||
m_shaderGraphReserved.InitializeShader();
|
||||
m_shaderGraphMono.InitializeShader();
|
||||
|
||||
m_resolution = m_graphyManager.RamGraphResolution;
|
||||
|
||||
CreatePoints();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods -> Private
|
||||
|
||||
private void Init()
|
||||
{
|
||||
m_graphyManager = transform.root.GetComponentInChildren<GraphyManager>();
|
||||
|
||||
m_ramMonitor = GetComponent<G_RamMonitor>();
|
||||
|
||||
m_shaderGraphAllocated = new G_GraphShader();
|
||||
m_shaderGraphReserved = new G_GraphShader();
|
||||
m_shaderGraphMono = new G_GraphShader();
|
||||
|
||||
m_shaderGraphAllocated.Image = m_imageAllocated;
|
||||
m_shaderGraphReserved.Image = m_imageReserved;
|
||||
m_shaderGraphMono.Image = m_imageMono;
|
||||
|
||||
UpdateParameters();
|
||||
|
||||
m_isInitialized = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Variables -> Serialized Private
|
||||
|
||||
[SerializeField] private Image m_imageAllocated;
|
||||
[SerializeField] private Image m_imageReserved;
|
||||
[SerializeField] private Image m_imageMono;
|
||||
|
||||
[SerializeField] private Shader ShaderFull;
|
||||
[SerializeField] private Shader ShaderLight;
|
||||
|
||||
[SerializeField] private bool m_isInitialized;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Variables -> Private
|
||||
|
||||
private GraphyManager m_graphyManager;
|
||||
|
||||
private G_RamMonitor m_ramMonitor;
|
||||
|
||||
private int m_resolution = 150;
|
||||
|
||||
private G_GraphShader m_shaderGraphAllocated;
|
||||
private G_GraphShader m_shaderGraphReserved;
|
||||
private G_GraphShader m_shaderGraphMono;
|
||||
|
||||
private float[] m_allocatedArray;
|
||||
private float[] m_reservedArray;
|
||||
private float[] m_monoArray;
|
||||
|
||||
private float m_highestMemory;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods -> Protected Override
|
||||
|
||||
protected override void UpdateGraph()
|
||||
{
|
||||
// Since we no longer initialize by default OnEnable(),
|
||||
// we need to check here, and Init() if needed
|
||||
if (!m_isInitialized) Init();
|
||||
|
||||
var allocatedMemory = m_ramMonitor.AllocatedRam;
|
||||
var reservedMemory = m_ramMonitor.ReservedRam;
|
||||
var monoMemory = m_ramMonitor.MonoRam;
|
||||
|
||||
m_highestMemory = 0;
|
||||
|
||||
for (var i = 0; i <= m_resolution - 1; i++)
|
||||
{
|
||||
if (i >= m_resolution - 1)
|
||||
{
|
||||
m_allocatedArray[i] = allocatedMemory;
|
||||
m_reservedArray[i] = reservedMemory;
|
||||
m_monoArray[i] = monoMemory;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_allocatedArray[i] = m_allocatedArray[i + 1];
|
||||
m_reservedArray[i] = m_reservedArray[i + 1];
|
||||
m_monoArray[i] = m_monoArray[i + 1];
|
||||
}
|
||||
|
||||
if (m_highestMemory < m_reservedArray[i]) m_highestMemory = m_reservedArray[i];
|
||||
}
|
||||
|
||||
for (var i = 0; i <= m_resolution - 1; i++)
|
||||
{
|
||||
m_shaderGraphAllocated.ShaderArrayValues[i] = m_allocatedArray[i] / m_highestMemory;
|
||||
|
||||
m_shaderGraphReserved.ShaderArrayValues[i] = m_reservedArray[i] / m_highestMemory;
|
||||
|
||||
m_shaderGraphMono.ShaderArrayValues[i] = m_monoArray[i] / m_highestMemory;
|
||||
}
|
||||
|
||||
m_shaderGraphAllocated.UpdatePoints();
|
||||
m_shaderGraphReserved.UpdatePoints();
|
||||
m_shaderGraphMono.UpdatePoints();
|
||||
}
|
||||
|
||||
protected override void CreatePoints()
|
||||
{
|
||||
if (m_shaderGraphAllocated.ShaderArrayValues == null ||
|
||||
m_shaderGraphAllocated.ShaderArrayValues.Length != m_resolution)
|
||||
{
|
||||
m_allocatedArray = new float[m_resolution];
|
||||
m_reservedArray = new float[m_resolution];
|
||||
m_monoArray = new float[m_resolution];
|
||||
|
||||
m_shaderGraphAllocated.ShaderArrayValues = new float[m_resolution];
|
||||
m_shaderGraphReserved.ShaderArrayValues = new float[m_resolution];
|
||||
m_shaderGraphMono.ShaderArrayValues = new float[m_resolution];
|
||||
}
|
||||
|
||||
for (var i = 0; i < m_resolution; i++)
|
||||
{
|
||||
m_shaderGraphAllocated.ShaderArrayValues[i] = 0;
|
||||
m_shaderGraphReserved.ShaderArrayValues[i] = 0;
|
||||
m_shaderGraphMono.ShaderArrayValues[i] = 0;
|
||||
}
|
||||
|
||||
// Initialize the material values
|
||||
|
||||
// Colors
|
||||
|
||||
m_shaderGraphAllocated.GoodColor = m_graphyManager.AllocatedRamColor;
|
||||
m_shaderGraphAllocated.CautionColor = m_graphyManager.AllocatedRamColor;
|
||||
m_shaderGraphAllocated.CriticalColor = m_graphyManager.AllocatedRamColor;
|
||||
|
||||
m_shaderGraphAllocated.UpdateColors();
|
||||
|
||||
m_shaderGraphReserved.GoodColor = m_graphyManager.ReservedRamColor;
|
||||
m_shaderGraphReserved.CautionColor = m_graphyManager.ReservedRamColor;
|
||||
m_shaderGraphReserved.CriticalColor = m_graphyManager.ReservedRamColor;
|
||||
|
||||
m_shaderGraphReserved.UpdateColors();
|
||||
|
||||
m_shaderGraphMono.GoodColor = m_graphyManager.MonoRamColor;
|
||||
m_shaderGraphMono.CautionColor = m_graphyManager.MonoRamColor;
|
||||
m_shaderGraphMono.CriticalColor = m_graphyManager.MonoRamColor;
|
||||
|
||||
m_shaderGraphMono.UpdateColors();
|
||||
|
||||
// Thresholds
|
||||
|
||||
m_shaderGraphAllocated.GoodThreshold = 0;
|
||||
m_shaderGraphAllocated.CautionThreshold = 0;
|
||||
m_shaderGraphAllocated.UpdateThresholds();
|
||||
|
||||
m_shaderGraphReserved.GoodThreshold = 0;
|
||||
m_shaderGraphReserved.CautionThreshold = 0;
|
||||
m_shaderGraphReserved.UpdateThresholds();
|
||||
|
||||
m_shaderGraphMono.GoodThreshold = 0;
|
||||
m_shaderGraphMono.CautionThreshold = 0;
|
||||
m_shaderGraphMono.UpdateThresholds();
|
||||
|
||||
m_shaderGraphAllocated.UpdateArray();
|
||||
m_shaderGraphReserved.UpdateArray();
|
||||
m_shaderGraphMono.UpdateArray();
|
||||
|
||||
// Average
|
||||
|
||||
m_shaderGraphAllocated.Average = 0;
|
||||
m_shaderGraphReserved.Average = 0;
|
||||
m_shaderGraphMono.Average = 0;
|
||||
|
||||
m_shaderGraphAllocated.UpdateAverage();
|
||||
m_shaderGraphReserved.UpdateAverage();
|
||||
m_shaderGraphMono.UpdateAverage();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9c49f1e95f2dab428b3a0ed56328a1c
|
||||
timeCreated: 1512484813
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,216 @@
|
||||
/* ---------------------------------------
|
||||
* Author: Martin Pane (martintayx@gmail.com) (@tayx94)
|
||||
* Contributors: https://github.com/Tayx94/graphy/graphs/contributors
|
||||
* Project: Graphy - Ultimate Stats Monitor
|
||||
* Date: 03-Jan-18
|
||||
* Studio: Tayx
|
||||
*
|
||||
* Git repo: https://github.com/Tayx94/graphy
|
||||
*
|
||||
* This project is released under the MIT license.
|
||||
* Attribution is not required, but it is always welcomed!
|
||||
* -------------------------------------*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Tayx.Graphy.UI;
|
||||
using Tayx.Graphy.Utils;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Tayx.Graphy.Ram
|
||||
{
|
||||
public class G_RamManager : MonoBehaviour, IMovable, IModifiableState
|
||||
{
|
||||
/* ----- TODO: ----------------------------
|
||||
* 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 "RamGraph".
|
||||
* Check why this manager doesnt use RamMonitor, as all the other managers have a monitor script.
|
||||
* Check if we should add a "RequireComponent" for "RamText".
|
||||
* --------------------------------------*/
|
||||
|
||||
#region Variables -> Serialized Private
|
||||
|
||||
[SerializeField] private GameObject m_ramGraphGameObject;
|
||||
|
||||
[SerializeField] private List<Image> m_backgroundImages = new();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Variables -> Private
|
||||
|
||||
private GraphyManager m_graphyManager;
|
||||
|
||||
private G_RamGraph m_ramGraph;
|
||||
private G_RamText m_ramText;
|
||||
|
||||
private RectTransform m_rectTransform;
|
||||
|
||||
private readonly List<GameObject> m_childrenGameObjects = new();
|
||||
|
||||
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)
|
||||
{
|
||||
var xSideOffset = Mathf.Abs(m_rectTransform.anchoredPosition.x);
|
||||
var 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:
|
||||
case GraphyManager.ModuleState.BASIC:
|
||||
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.BACKGROUND:
|
||||
gameObject.SetActive(true);
|
||||
SetGraphActive(false);
|
||||
|
||||
m_childrenGameObjects.SetAllActive(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_ramGraph.UpdateParameters();
|
||||
m_ramText.UpdateParameters();
|
||||
|
||||
SetState(m_graphyManager.RamModuleState);
|
||||
}
|
||||
|
||||
public void RefreshParameters()
|
||||
{
|
||||
foreach (var image in m_backgroundImages) image.color = m_graphyManager.BackgroundColor;
|
||||
|
||||
m_ramGraph.UpdateParameters();
|
||||
m_ramText.UpdateParameters();
|
||||
|
||||
SetState(m_currentModuleState, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods -> Private
|
||||
|
||||
private void Init()
|
||||
{
|
||||
m_graphyManager = transform.root.GetComponentInChildren<GraphyManager>();
|
||||
|
||||
m_ramGraph = GetComponent<G_RamGraph>();
|
||||
m_ramText = GetComponent<G_RamText>();
|
||||
|
||||
m_rectTransform = GetComponent<RectTransform>();
|
||||
|
||||
foreach (Transform child in transform)
|
||||
if (child.parent == transform)
|
||||
m_childrenGameObjects.Add(child.gameObject);
|
||||
}
|
||||
|
||||
private void SetGraphActive(bool active)
|
||||
{
|
||||
m_ramGraph.enabled = active;
|
||||
m_ramGraphGameObject.SetActive(active);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84f7591c01b7f1a4ab82f1a0038491da
|
||||
timeCreated: 1514998367
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,42 @@
|
||||
/* ---------------------------------------
|
||||
* Author: Martin Pane (martintayx@gmail.com) (@tayx94)
|
||||
* Contributors: https://github.com/Tayx94/graphy/graphs/contributors
|
||||
* Project: Graphy - Ultimate Stats Monitor
|
||||
* Date: 15-Dec-17
|
||||
* Studio: Tayx
|
||||
*
|
||||
* Git repo: https://github.com/Tayx94/graphy
|
||||
*
|
||||
* This project is released under the MIT license.
|
||||
* Attribution is not required, but it is always welcomed!
|
||||
* -------------------------------------*/
|
||||
|
||||
using UnityEngine;
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
using UnityEngine.Profiling;
|
||||
#endif
|
||||
|
||||
namespace Tayx.Graphy.Ram
|
||||
{
|
||||
public class G_RamMonitor : MonoBehaviour
|
||||
{
|
||||
#region Methods -> Unity Callbacks
|
||||
|
||||
private void Update()
|
||||
{
|
||||
AllocatedRam = Profiler.GetTotalAllocatedMemoryLong() / 1048576f;
|
||||
ReservedRam = Profiler.GetTotalReservedMemoryLong() / 1048576f;
|
||||
MonoRam = Profiler.GetMonoUsedSizeLong() / 1048576f;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties -> Public
|
||||
|
||||
public float AllocatedRam { get; private set; }
|
||||
public float ReservedRam { get; private set; }
|
||||
public float MonoRam { get; private set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2494656f0dd693144be1306d5551e544
|
||||
timeCreated: 1513377000
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,96 @@
|
||||
/* ---------------------------------------
|
||||
* Author: Martin Pane (martintayx@gmail.com) (@tayx94)
|
||||
* Contributors: https://github.com/Tayx94/graphy/graphs/contributors
|
||||
* Project: Graphy - Ultimate Stats Monitor
|
||||
* Date: 05-Dec-17
|
||||
* Studio: Tayx
|
||||
*
|
||||
* Git repo: https://github.com/Tayx94/graphy
|
||||
*
|
||||
* This project is released under the MIT license.
|
||||
* Attribution is not required, but it is always welcomed!
|
||||
* -------------------------------------*/
|
||||
|
||||
using Tayx.Graphy.Utils.NumString;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Tayx.Graphy.Ram
|
||||
{
|
||||
public class G_RamText : MonoBehaviour
|
||||
{
|
||||
#region Methods -> Public
|
||||
|
||||
public void UpdateParameters()
|
||||
{
|
||||
m_allocatedSystemMemorySizeText.color = m_graphyManager.AllocatedRamColor;
|
||||
m_reservedSystemMemorySizeText.color = m_graphyManager.ReservedRamColor;
|
||||
m_monoSystemMemorySizeText.color = m_graphyManager.MonoRamColor;
|
||||
|
||||
m_updateRate = m_graphyManager.RamTextUpdateRate;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods -> Private
|
||||
|
||||
private void Init()
|
||||
{
|
||||
// We assume no game will consume more than 16GB of RAM.
|
||||
// If it does, who cares about some minuscule garbage allocation lol.
|
||||
G_IntString.Init(0, 16386);
|
||||
|
||||
m_graphyManager = transform.root.GetComponentInChildren<GraphyManager>();
|
||||
|
||||
m_ramMonitor = GetComponent<G_RamMonitor>();
|
||||
|
||||
UpdateParameters();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Variables -> Serialized Private
|
||||
|
||||
[SerializeField] private Text m_allocatedSystemMemorySizeText;
|
||||
[SerializeField] private Text m_reservedSystemMemorySizeText;
|
||||
[SerializeField] private Text m_monoSystemMemorySizeText;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Variables -> Private
|
||||
|
||||
private GraphyManager m_graphyManager;
|
||||
|
||||
private G_RamMonitor m_ramMonitor;
|
||||
|
||||
private float m_updateRate = 4f; // 4 updates per sec.
|
||||
|
||||
private float m_deltaTime;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods -> Unity Callbacks
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
m_deltaTime += Time.unscaledDeltaTime;
|
||||
|
||||
if (m_deltaTime > 1f / m_updateRate)
|
||||
{
|
||||
// Update allocated, mono and reserved memory
|
||||
m_allocatedSystemMemorySizeText.text = ((int)m_ramMonitor.AllocatedRam).ToStringNonAlloc();
|
||||
m_reservedSystemMemorySizeText.text = ((int)m_ramMonitor.ReservedRam).ToStringNonAlloc();
|
||||
m_monoSystemMemorySizeText.text = ((int)m_ramMonitor.MonoRam).ToStringNonAlloc();
|
||||
|
||||
m_deltaTime = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28d32ee74b6e6d24ea89d1b477060318
|
||||
timeCreated: 1512484799
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user