mirror of
https://github.com/DCFApixels/Unity-DebugX.git
synced 2026-04-21 20:35:54 +08:00
Merge branch 'dev'
This commit is contained in:
commit
c84aa33113
@ -32,22 +32,23 @@ namespace DCFApixels.DebugXCore.Internal
|
||||
private void OnGUI()
|
||||
{
|
||||
_pos = GUILayout.BeginScrollView(_pos, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
|
||||
float tmpValue;
|
||||
float tmpFloat;
|
||||
int tmpInt;
|
||||
|
||||
DebugX.GlobalTimeScale = EditorGUILayout.FloatField("TimeScale", DebugX.GlobalTimeScale);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
tmpValue = EditorGUILayout.Slider(DebugX.GlobalTimeScale, 0, 2);
|
||||
tmpFloat = EditorGUILayout.Slider(DebugX.GlobalTimeScale, 0, 2);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
DebugX.GlobalTimeScale = tmpValue;
|
||||
DebugX.GlobalTimeScale = tmpFloat;
|
||||
}
|
||||
|
||||
DebugX.GlobalDotSize = EditorGUILayout.FloatField("DotSize", DebugX.GlobalDotSize);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
tmpValue = EditorGUILayout.Slider(DebugX.GlobalDotSize, 0, 2);
|
||||
tmpFloat = EditorGUILayout.Slider(DebugX.GlobalDotSize, 0, 2);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
DebugX.GlobalDotSize = tmpValue;
|
||||
DebugX.GlobalDotSize = tmpFloat;
|
||||
}
|
||||
|
||||
DebugX.GlobalColor = EditorGUILayout.ColorField("Color", DebugX.GlobalColor);
|
||||
@ -58,12 +59,16 @@ namespace DCFApixels.DebugXCore.Internal
|
||||
|
||||
DebugX.GlobalGreaterPassAlpha = EditorGUILayout.FloatField("GreaterPassAlpha", DebugX.GlobalGreaterPassAlpha);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
tmpValue = EditorGUILayout.Slider(DebugX.GlobalGreaterPassAlpha, 0, 1);
|
||||
tmpFloat = EditorGUILayout.Slider(DebugX.GlobalGreaterPassAlpha, 0, 1);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
DebugX.GlobalGreaterPassAlpha = tmpValue;
|
||||
DebugX.GlobalGreaterPassAlpha = tmpFloat;
|
||||
}
|
||||
|
||||
DebugX.AvailablePoolMemory = EditorGUILayout.IntField("AvailablePoolMemory (kb)", DebugX.AvailablePoolMemory);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
|
||||
if (GUILayout.Button("Reset"))
|
||||
{
|
||||
DebugX.ResetGlobals();
|
||||
|
||||
@ -27,6 +27,7 @@ namespace DCFApixels
|
||||
private const string GLOBAL_DOT_SIZE_PREF_NAME = "DCFApixels.DebugX.DotSize";
|
||||
private const string GLOBAL_COLOR_PREF_NAME = "DCFApixels.DebugX.Color";
|
||||
private const string GLOBAL_GREATER_PASS_ALPHA_PREF_NAME = "DCFApixels.DebugX.GreaterPassAlpha";
|
||||
private const string GLOBAL_AVAILABLE_POOL_MEMORY_PREF_NAME = "DCFApixels.DebugX.AvailablePoolMemory";
|
||||
|
||||
private readonly static int GlobalDotSizePropertyID = Shader.PropertyToID("_DebugX_GlobalDotSize");
|
||||
private readonly static int GlobalColorPropertyID = Shader.PropertyToID("_DebugX_GlobalColor");
|
||||
|
||||
@ -17,6 +17,8 @@ using UnityEngine.PlayerLoop;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
using DCFApixels.DebugXCore.Internal;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DCFApixels
|
||||
{
|
||||
@ -661,6 +663,25 @@ namespace DCFApixels
|
||||
}
|
||||
private class GizmosBuffer<T> : GizmosBuffer where T : IGizmo<T>
|
||||
{
|
||||
private static int _lastAvailablePoolMemory;
|
||||
private static int _bufferMaxSize;
|
||||
private static readonly int _elementSize = RuntimeHelpers.IsReferenceOrContainsReferences<T>() ? sizeof(IntPtr) : Marshal.SizeOf<T>();
|
||||
private static void CheckAvailablePoolMemory()
|
||||
{
|
||||
if(_bufferMaxSize != 0 && _lastAvailablePoolMemory == DebugX.AvailablePoolMemory)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(DebugX.AvailablePoolMemory < _elementSize * 10)
|
||||
{
|
||||
_bufferMaxSize = DebugX.AvailablePoolMemory * 1024 / _elementSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
_bufferMaxSize = DebugX.AvailablePoolMemory / _elementSize * 1024;
|
||||
}
|
||||
_lastAvailablePoolMemory = DebugX.AvailablePoolMemory;
|
||||
}
|
||||
private class DummyRenderer : IGizmoRenderer<T>
|
||||
{
|
||||
public int ExecuteOrder { get { return 0; } }
|
||||
@ -714,17 +735,24 @@ namespace DCFApixels
|
||||
[IN(LINE)]
|
||||
public void Add(T value, float time, Color color)
|
||||
{
|
||||
CheckAvailablePoolMemory();
|
||||
if ((_gizmos.Count + 1) >= _bufferMaxSize) { return; }
|
||||
|
||||
_gizmos.Add(new GizmoInternal<T>(value, time, color));
|
||||
}
|
||||
[IN(LINE)]
|
||||
public void AddRange(ReadOnlySpan<T> values, float time, Color color)
|
||||
{
|
||||
CheckAvailablePoolMemory();
|
||||
if ((_gizmos.Count + values.Length) >= _bufferMaxSize) { return; }
|
||||
|
||||
_gizmos.UpSize(_gizmos._count + values.Length);
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
_gizmos.Add(new GizmoInternal<T>(values[i], time, color));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public sealed override int UpdateTimer(float deltaTime)
|
||||
{
|
||||
|
||||
@ -67,6 +67,20 @@ namespace DCFApixels
|
||||
|
||||
#if UNITY_EDITOR
|
||||
EditorPrefs.SetFloat(GLOBAL_GREATER_PASS_ALPHA_PREF_NAME, _globalGreaterPassAlphaCache);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
private static int _availablePoolMemory; //KB
|
||||
public static int AvailablePoolMemory
|
||||
{
|
||||
get { return _availablePoolMemory; }
|
||||
set
|
||||
{
|
||||
value = Mathf.Max(0, value);
|
||||
if (_availablePoolMemory == value) { return; }
|
||||
_availablePoolMemory = value;
|
||||
#if UNITY_EDITOR
|
||||
EditorPrefs.SetInt(GLOBAL_AVAILABLE_POOL_MEMORY_PREF_NAME, value);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -77,6 +91,7 @@ namespace DCFApixels
|
||||
EditorPrefs.DeleteKey(GLOBAL_DOT_SIZE_PREF_NAME);
|
||||
EditorPrefs.DeleteKey(GLOBAL_COLOR_PREF_NAME);
|
||||
EditorPrefs.DeleteKey(GLOBAL_GREATER_PASS_ALPHA_PREF_NAME);
|
||||
EditorPrefs.DeleteKey(GLOBAL_AVAILABLE_POOL_MEMORY_PREF_NAME);
|
||||
#endif
|
||||
_timeScaleCache = default;
|
||||
_dotSizeCache = default;
|
||||
@ -92,11 +107,13 @@ namespace DCFApixels
|
||||
var colorCode = EditorPrefs.GetInt(GLOBAL_COLOR_PREF_NAME, -1);
|
||||
GlobalColor = (Color)(*(Color32*)&colorCode);
|
||||
GlobalGreaterPassAlpha = EditorPrefs.GetFloat(GLOBAL_GREATER_PASS_ALPHA_PREF_NAME, 0.1f);
|
||||
AvailablePoolMemory = EditorPrefs.GetInt(GLOBAL_AVAILABLE_POOL_MEMORY_PREF_NAME, 524288);
|
||||
#else
|
||||
GlobalTimeScale = 1;
|
||||
GlobalDotSize = 1;
|
||||
GlobalColor = Color.white;
|
||||
GlobalGreaterPassAlpha = 0.1f;
|
||||
AvailablePoolMemory = 524288;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ namespace DCFApixels
|
||||
_singleWarningToggle = false;
|
||||
}
|
||||
#endif
|
||||
settings = settings.SetSize(DebugXTextSettings.DEFAULT_FONT_SIZE);
|
||||
settings = settings.Size(DebugXTextSettings.DEFAULT_FONT_SIZE);
|
||||
}
|
||||
return h.Gizmo(new TextGizmo(position, text, settings));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user