Skip to content

Commit

Permalink
Attribute Naming & Exception Logging Update
Browse files Browse the repository at this point in the history
• Updated internal exception handling.
• Reworked multiple meta attributes. Attributes related to monitoring (MonitoringMetaAttributes) are now prefixed with a capital M.
• Improved event monitoring for IL2CPP
  • Loading branch information
JohnBaracuda committed Jun 5, 2022
1 parent 5b52e99 commit de9ac84
Show file tree
Hide file tree
Showing 63 changed files with 678 additions and 462 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ public class MonitoringSettingsInspector : UnityEditor.Editor
private SerializedProperty _vectorFormat;
private SerializedProperty _quaternionFormat;

private SerializedProperty _classColor;
private SerializedProperty _trueColor;
private SerializedProperty _falseColor;
private SerializedProperty _xColor;
private SerializedProperty _yColor;
private SerializedProperty _zColor;
private SerializedProperty _wColor;
private SerializedProperty _classColor;
private SerializedProperty _eventColor;

private SerializedProperty _bannedAssemblyPrefixes;
private SerializedProperty _bannedAssemblyNames;
Expand Down Expand Up @@ -191,13 +192,14 @@ public void DrawCustomInspector()
if (Foldout["Color"])
{
EditorGUILayout.Space();
EditorGUILayout.PropertyField(_classColor);
EditorGUILayout.PropertyField(_trueColor);
EditorGUILayout.PropertyField(_falseColor);
EditorGUILayout.PropertyField(_xColor);
EditorGUILayout.PropertyField(_yColor);
EditorGUILayout.PropertyField(_zColor);
EditorGUILayout.PropertyField(_wColor);
EditorGUILayout.PropertyField(_classColor);
EditorGUILayout.PropertyField(_eventColor);
EditorGUILayout.Space();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2022 Jonathan Lang

using System;
using System.Text;
using UnityEngine;
Expand Down Expand Up @@ -30,21 +31,12 @@ public class FPSMonitor : MonitoredSingleton<FPSMonitor>
* FPS Monitor
*/

[MonitorValue(UpdateEvent = nameof(FPSUpdated))]
[ValueProcessor(nameof(FPSProcessor))]
[Format(FontSize = 32, Position = UIPosition.UpperRight, GroupElement = false)]
[Monitor]
[MValueProcessor(nameof(FPSProcessor))]
[MUpdateEvent(nameof(FPSUpdated))]
[MFormatOptions(FontSize = 32, Position = UIPosition.UpperRight, GroupElement = false)]
private float _fps;

#if FPS_MONITOR_TOTAL
[MonitorValue(Update = UpdateOptions.TickUpdate)]
#endif
private long _totalFrameCount = 0;

#if FPS_MONITOR_TOTAL_FIXED
[MonitorValue(Update = UpdateOptions.TickUpdate)]
#endif
private long _fixedUpdateCount = 0;

/*
* Events
*/
Expand All @@ -53,14 +45,6 @@ public class FPSMonitor : MonitoredSingleton<FPSMonitor>

//--------------------------------------------------------------------------------------------------------------

#if FPS_MONITOR_FORCE
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
private static void InitializeOnLoad()
{
Promise();
}
#endif

public static string FPSProcessor(float value)
{
stringBuilder.Clear();
Expand All @@ -74,7 +58,6 @@ public static string FPSProcessor(float value)
private void Update()
{
frameCount++;
_totalFrameCount++;
timer += Time.deltaTime / Time.timeScale;

if (timer < MEASURE_PERIOD)
Expand All @@ -98,16 +81,11 @@ private void Update()
timer = rest;
}

private void FixedUpdate()
{
_fixedUpdateCount++;
}

#region --- Vsync ---

[Monitor]
[Format(FontSize = 16, Position = UIPosition.UpperRight, GroupElement = false)]
[ValueProcessor(nameof(ProcessorTargetFrameRate))]
[MFormatOptions(FontSize = 16, Position = UIPosition.UpperRight, GroupElement = false)]
[MValueProcessor(nameof(ProcessorTargetFrameRate))]
private int TargetFrameRate => Application.targetFrameRate;

private static string ProcessorTargetFrameRate(int value)
Expand All @@ -116,8 +94,8 @@ private static string ProcessorTargetFrameRate(int value)
}

[Monitor]
[Format(FontSize = 16, Position = UIPosition.UpperRight, GroupElement = false)]
[ValueProcessor(nameof(ProcessorVsync))]
[MFormatOptions(FontSize = 16, Position = UIPosition.UpperRight, GroupElement = false)]
[MValueProcessor(nameof(ProcessorVsync))]
private int Vsync => QualitySettings.vSyncCount;

private static string ProcessorVsync(int value)
Expand Down
14 changes: 11 additions & 3 deletions Assets/Baracuda/Monitoring.Example/Scripts/PlayerWeapon.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2022 Jonathan Lang
using Baracuda.Monitoring.API;

using System;
using Baracuda.Pooling.Concretions;
using UnityEngine;

Expand Down Expand Up @@ -35,10 +36,14 @@ public class PlayerWeapon : MonitoredBehaviour
*/

[Monitor]
[Format(UIPosition.LowerLeft, FontSize = 20)]
[ValueProcessor(nameof(CurrentAmmunitionProcessor))]
[MUpdateEvent(nameof(OnAmmoChanged))]
[MFormatOptions(UIPosition.LowerLeft, FontSize = 20)]
[MValueProcessor(nameof(CurrentAmmunitionProcessor))]
private int _currentAmmunition;

[Monitor]
private event Action<int> OnAmmoChanged;

private float _lastFireTime;
private float _targetFOV;
private IPlayerInput _input;
Expand Down Expand Up @@ -75,6 +80,7 @@ protected override void Awake()
_input = GetComponent<IPlayerInput>();
_camera = GetComponentInChildren<Camera>();
_currentAmmunition = ammunition;
OnAmmoChanged?.Invoke(_currentAmmunition);
}

private void Update()
Expand All @@ -93,6 +99,7 @@ private void Update()
for (var i = 0; i < bulletsPerShot; i++)
{
_currentAmmunition--;
OnAmmoChanged?.Invoke(_currentAmmunition);
var projectile = projectilePool.GetProjectileFromPool();
projectile.Setup(
position: projectileSpawnPosition.position,
Expand Down Expand Up @@ -130,6 +137,7 @@ private void PreformRaycast()
public void ReplenishAmmunition()
{
_currentAmmunition = ammunition;
OnAmmoChanged?.Invoke(_currentAmmunition);
}

#endregion
Expand Down
21 changes: 10 additions & 11 deletions Assets/Baracuda/Monitoring.UI/IMGUI/MonitoringGUIDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
namespace Baracuda.Monitoring.UI.IMGUI
{
/// <summary>
/// Disclaimer:
/// Disclaimer!!!
/// This class is showing the base for a GUI based monitoring UI Controller.
/// I recommend using either the TextMesh Pro based uGUI solution or the UIToolkit solution instead.
/// </summary>
public class MonitoringGUIDrawer : MonitoringUIController
{
Expand Down Expand Up @@ -69,16 +70,14 @@ private class GUIElement
public FormatData FormatData { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; }

private readonly int _size;
private readonly string _targetName;

public GUIElement(IMonitorUnit unit)
{
unit.ValueUpdated += Update;
FormatData = unit.Profile.FormatData;
ID = unit.ID;
_targetName = unit.Profile.UnitTargetType.Name;
ID = unit.UniqueID;
_size = Mathf.Max(FormatData.FontSize, 14);
Update(unit.GetStateFormatted);
Update(unit.GetState());
}

private void Update(string text)
Expand All @@ -101,8 +100,8 @@ private readonly ref struct ScreenData

public ScreenData(float width, float height)
{
this.Width = width;
this.Height = height;
Width = width;
Height = height;
HalfHeight = height * .5f;
}
}
Expand Down Expand Up @@ -475,16 +474,16 @@ private void OnUnitDisposedInternal(IMonitorUnit unit)
switch (unit.Profile.FormatData.Position)
{
case UIPosition.UpperLeft:
_unitsUpperLeft.Remove(_unitsUpperLeft.First(element => element.ID == unit.ID));
_unitsUpperLeft.Remove(_unitsUpperLeft.First(element => element.ID == unit.UniqueID));
break;
case UIPosition.UpperRight:
_unitsUpperRight.Remove(_unitsUpperRight.First(element => element.ID == unit.ID));
_unitsUpperRight.Remove(_unitsUpperRight.First(element => element.ID == unit.UniqueID));
break;
case UIPosition.LowerLeft:
_unitsLowerLeft.Remove(_unitsLowerLeft.First(element => element.ID == unit.ID));
_unitsLowerLeft.Remove(_unitsLowerLeft.First(element => element.ID == unit.UniqueID));
break;
case UIPosition.LowerRight:
_unitsLowerRight.Remove(_unitsLowerRight.First(element => element.ID == unit.ID));
_unitsLowerRight.Remove(_unitsLowerRight.First(element => element.ID == unit.UniqueID));
break;
}
}
Expand Down
Binary file modified Assets/Baracuda/Monitoring.UI/RuntimeMonitoring_IMGUI.unitypackage
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Setup(IMonitorUnit monitorUnit)
}

monitorUnit.ValueUpdated += _updateValue;
_updateValue(monitorUnit.GetStateFormatted);
_updateValue(monitorUnit.GetState());
}

#endregion
Expand Down
Loading

0 comments on commit de9ac84

Please sign in to comment.