123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- 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<PlotFileWriter> plotWriters = new List<PlotFileWriter>();
- private Process plottingProc;
- private DebugPlot()
- { }
- public PlotFileWriter StartPlotting(string path)
- {
- var writer = new PlotFileWriter(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();
- }
- }
- }
- }
|