特效新内容。修复gameplay致命bug和分数保存bug
This commit is contained in:
@@ -0,0 +1,264 @@
|
||||
/* ---------------------------------------
|
||||
* Author: Martin Pane (martintayx@gmail.com) (@martinTayx)
|
||||
* 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;
|
||||
|
||||
namespace Tayx.Graphy.Ram
|
||||
{
|
||||
public class G_RamGraph : G_Graph
|
||||
{
|
||||
#region Variables -> Serialized Private
|
||||
|
||||
[SerializeField] private Image m_imageAllocated = null;
|
||||
[SerializeField] private Image m_imageReserved = null;
|
||||
[SerializeField] private Image m_imageMono = null;
|
||||
|
||||
[SerializeField] private Shader ShaderFull = null;
|
||||
[SerializeField] private Shader ShaderLight = null;
|
||||
|
||||
[SerializeField] private bool m_isInitialized = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Variables -> Private
|
||||
|
||||
private GraphyManager m_graphyManager = null;
|
||||
|
||||
private G_RamMonitor m_ramMonitor = null;
|
||||
|
||||
private int m_resolution = 150;
|
||||
|
||||
private G_GraphShader m_shaderGraphAllocated = null;
|
||||
private G_GraphShader m_shaderGraphReserved = null;
|
||||
private G_GraphShader m_shaderGraphMono = null;
|
||||
|
||||
private float[] m_allocatedArray;
|
||||
private float[] m_reservedArray;
|
||||
private float[] m_monoArray;
|
||||
|
||||
private float m_highestMemory = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#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 -> 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();
|
||||
}
|
||||
|
||||
float allocatedMemory = m_ramMonitor.AllocatedRam;
|
||||
float reservedMemory = m_ramMonitor.ReservedRam;
|
||||
float monoMemory = m_ramMonitor.MonoRam;
|
||||
|
||||
m_highestMemory = 0;
|
||||
|
||||
for( int 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( int 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( int 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.UpdateArrayValuesLength();
|
||||
m_shaderGraphReserved.UpdateArrayValuesLength();
|
||||
m_shaderGraphMono.UpdateArrayValuesLength();
|
||||
|
||||
// Average
|
||||
|
||||
m_shaderGraphAllocated.Average = 0;
|
||||
m_shaderGraphReserved.Average = 0;
|
||||
m_shaderGraphMono.Average = 0;
|
||||
|
||||
m_shaderGraphAllocated.UpdateAverage();
|
||||
m_shaderGraphReserved.UpdateAverage();
|
||||
m_shaderGraphMono.UpdateAverage();
|
||||
}
|
||||
|
||||
#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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9c49f1e95f2dab428b3a0ed56328a1c
|
||||
timeCreated: 1512484813
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 105778
|
||||
packageName: '[Graphy] - Ultimate FPS Counter - Stats Monitor & Debugger'
|
||||
packageVersion: 3.0.5
|
||||
assetPath: Assets/Graphy - Ultimate Stats Monitor/Runtime/Ram/G_RamGraph.cs
|
||||
uploadId: 626547
|
||||
@@ -0,0 +1,232 @@
|
||||
/* ---------------------------------------
|
||||
* Author: Martin Pane (martintayx@gmail.com) (@martinTayx)
|
||||
* 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 UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using Tayx.Graphy.UI;
|
||||
using Tayx.Graphy.Utils;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Tayx.Graphy.Ram
|
||||
{
|
||||
public class G_RamManager : MonoBehaviour, IMovable, IModifiableState
|
||||
{
|
||||
#region Variables -> Serialized Private
|
||||
|
||||
[SerializeField] private GameObject m_ramGraphGameObject = null;
|
||||
|
||||
[SerializeField] private List<Image> m_backgroundImages = new List<Image>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Variables -> Private
|
||||
|
||||
private GraphyManager m_graphyManager = null;
|
||||
|
||||
private G_RamGraph m_ramGraph = null;
|
||||
private G_RamText m_ramText = null;
|
||||
|
||||
private RectTransform m_rectTransform = null;
|
||||
private Vector2 m_origPosition = Vector2.zero;
|
||||
|
||||
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, Vector2 offset )
|
||||
{
|
||||
if ( newModulePosition == GraphyManager.ModulePosition.FREE )
|
||||
return;
|
||||
|
||||
m_rectTransform.anchoredPosition = m_origPosition;
|
||||
|
||||
float xSideOffset = Mathf.Abs( m_rectTransform.anchoredPosition.x ) + offset.x;
|
||||
float ySideOffset = Mathf.Abs( m_rectTransform.anchoredPosition.y ) + offset.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;
|
||||
}
|
||||
}
|
||||
|
||||
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>();
|
||||
m_origPosition = m_rectTransform.anchoredPosition;
|
||||
|
||||
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,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84f7591c01b7f1a4ab82f1a0038491da
|
||||
timeCreated: 1514998367
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 105778
|
||||
packageName: '[Graphy] - Ultimate FPS Counter - Stats Monitor & Debugger'
|
||||
packageVersion: 3.0.5
|
||||
assetPath: Assets/Graphy - Ultimate Stats Monitor/Runtime/Ram/G_RamManager.cs
|
||||
uploadId: 626547
|
||||
@@ -0,0 +1,40 @@
|
||||
/* ---------------------------------------
|
||||
* Author: Martin Pane (martintayx@gmail.com) (@martinTayx)
|
||||
* 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;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
namespace Tayx.Graphy.Ram
|
||||
{
|
||||
public class G_RamMonitor : MonoBehaviour
|
||||
{
|
||||
#region Properties -> Public
|
||||
|
||||
public float AllocatedRam { get; private set; }
|
||||
public float ReservedRam { get; private set; }
|
||||
public float MonoRam { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods -> Unity Callbacks
|
||||
|
||||
private void Update()
|
||||
{
|
||||
AllocatedRam = Profiler.GetTotalAllocatedMemoryLong() / 1048576f;
|
||||
ReservedRam = Profiler.GetTotalReservedMemoryLong() / 1048576f;
|
||||
MonoRam = Profiler.GetMonoUsedSizeLong() / 1048576f;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2494656f0dd693144be1306d5551e544
|
||||
timeCreated: 1513377000
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 105778
|
||||
packageName: '[Graphy] - Ultimate FPS Counter - Stats Monitor & Debugger'
|
||||
packageVersion: 3.0.5
|
||||
assetPath: Assets/Graphy - Ultimate Stats Monitor/Runtime/Ram/G_RamMonitor.cs
|
||||
uploadId: 626547
|
||||
@@ -0,0 +1,96 @@
|
||||
/* ---------------------------------------
|
||||
* Author: Martin Pane (martintayx@gmail.com) (@martinTayx)
|
||||
* 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 UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Tayx.Graphy.Utils.NumString;
|
||||
|
||||
namespace Tayx.Graphy.Ram
|
||||
{
|
||||
public class G_RamText : MonoBehaviour
|
||||
{
|
||||
#region Variables -> Serialized Private
|
||||
|
||||
[SerializeField] private Text m_allocatedSystemMemorySizeText = null;
|
||||
[SerializeField] private Text m_reservedSystemMemorySizeText = null;
|
||||
[SerializeField] private Text m_monoSystemMemorySizeText = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Variables -> Private
|
||||
|
||||
private GraphyManager m_graphyManager = null;
|
||||
|
||||
private G_RamMonitor m_ramMonitor = null;
|
||||
|
||||
private float m_updateRate = 4f; // 4 updates per sec.
|
||||
|
||||
private float m_deltaTime = 0.0f;
|
||||
|
||||
#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
|
||||
|
||||
#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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28d32ee74b6e6d24ea89d1b477060318
|
||||
timeCreated: 1512484799
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 105778
|
||||
packageName: '[Graphy] - Ultimate FPS Counter - Stats Monitor & Debugger'
|
||||
packageVersion: 3.0.5
|
||||
assetPath: Assets/Graphy - Ultimate Stats Monitor/Runtime/Ram/G_RamText.cs
|
||||
uploadId: 626547
|
||||
Reference in New Issue
Block a user