using UnityEngine; using System.Collections.Generic; using System.Linq; public class ForceCurveDataLogger : MonoBehaviour { private List _strokeBuffer = new List(); void Start() { if (PerformanceMonitorManager.Instance != null) PerformanceMonitorManager.Instance.OnForceCurveUpdated += HandleData; } void HandleData(List points) { // 1. SIGNAL: Manager sends empty list when a NEW stroke starts if (points.Count == 0) { if (_strokeBuffer.Count > 5) { LogFinishedStroke(); } _strokeBuffer.Clear(); } else { // 2. Accumulate the cumulative data _strokeBuffer = new List(points); } } void LogFinishedStroke() { float maxForce = _strokeBuffer.Max(); float totalImpulse = _strokeBuffer.Sum(); // Area under the curve string csv = string.Join(",", _strokeBuffer.Select(p => p.ToString("0"))); Debug.Log($"[STROKE RECORDED] Impulse: {totalImpulse:N0} | Pts: {_strokeBuffer.Count} | Max: {maxForce}"); Debug.Log("CSV:" + csv); } }