1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using Logging;
- using Logging.Base;
- using UnityEngine;
- namespace Plotting
- {
- public class DebugPlot
- {
- #region signleton
- private static Lazy<DebugPlot>
- instance =
- new Lazy<DebugPlot>
- (() => new DebugPlot());
- public static DebugPlot Instance => instance.Value;
- public static void DestroyInstance()
- {
- if (instance.IsValueCreated)
- {
- instance.Value.Dispose();
- instance =
- new Lazy<DebugPlot>
- (() => new DebugPlot());
- }
- }
- #endregion
- private List<AsyncLogFileWriter> plotWriters = new List<AsyncLogFileWriter>();
- private Process plottingProc;
- private DebugPlot()
- { }
- public AsyncLogFileWriter StartPlotting(string path)
- {
- var writer = new AsyncLogFileWriter(path);
- plotWriters.Add(writer);
- return writer;
- }
- public void ShowPlots()
- {
- plottingProc = Process.Start("CMD.exe",$"/C cd Assets/Plotting & python plot.py");
- }
- private void Dispose()
- {
- plottingProc?.Kill();
- foreach (var p in plotWriters)
- {
- p.Dispose();
- }
- }
- }
- }
|