|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
[MenuItem("Window/Visualizer/Open")] |
|
|
|
public static async Task RunVisualizerButton() |
|
|
|
{ |
|
|
|
var project = Application.dataPath; |
|
|
|
await RunVisualizer(project); |
|
|
|
} |
|
|
|
[MenuItem("Window/Visualizer/Run")] |
|
|
|
public static async Task RunVisualizer() |
|
|
|
public static async Task RunVisualizer(string project) |
|
|
|
if (!CheckIfVisualizerInstalled()) |
|
|
|
if (!CheckIfVisualizerInstalled(project)) |
|
|
|
|
|
|
|
//The dataPath is used as a unique identifier for the project
|
|
|
|
var project = Application.dataPath; |
|
|
|
|
|
|
|
var (pythonPid, port, visualizerPid) = ReadEntry(project); |
|
|
|
|
|
|
|
|
|
|
var before = Process.GetProcesses(); |
|
|
|
|
|
|
|
EditorUtility.DisplayProgressBar("Opening Visualizer", "Running executable", 1f / 4); |
|
|
|
var errorCode = ExecuteVisualizer(); |
|
|
|
var errorCode = ExecuteVisualizer(project); |
|
|
|
if (errorCode == -1) |
|
|
|
{ |
|
|
|
EditorUtility.ClearProgressBar(); |
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Runs visualizer instance (streamlit) from the python for unity install
|
|
|
|
/// </summary>
|
|
|
|
static int ExecuteVisualizer() |
|
|
|
static int ExecuteVisualizer(string project) |
|
|
|
var packagesPath = Path.GetFullPath(Application.dataPath.Replace("/Assets", "/Library/PythonInstall/Scripts")); |
|
|
|
var packagesPath = Path.GetFullPath(project.Replace("/Assets", "/Library/PythonInstall/Scripts")); |
|
|
|
var packagesPath = Application.dataPath.Replace("/Assets","/Library/PythonInstall/bin"); |
|
|
|
var packagesPath = project.Replace("/Assets","/Library/PythonInstall/bin"); |
|
|
|
#endif
|
|
|
|
|
|
|
|
var pathToData = PlayerPrefs.GetString(SimulationState.latestOutputDirectoryKey); |
|
|
|
|
|
|
[MenuItem("Window/Visualizer/Check For Updates")] |
|
|
|
static async Task CheckForUpdates() |
|
|
|
{ |
|
|
|
if (!CheckIfVisualizerInstalled()) |
|
|
|
var project = Application.dataPath; |
|
|
|
if (!CheckIfVisualizerInstalled(project)) |
|
|
|
{ |
|
|
|
if (EditorUtility.DisplayDialog("Visualizer not Installed", |
|
|
|
$"The visualizer is not yet installed, do you wish to install it?", |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static bool CheckIfVisualizerInstalled() |
|
|
|
static bool CheckIfVisualizerInstalled(string project) |
|
|
|
var packagesPath = Path.GetFullPath(Application.dataPath.Replace("/Assets", "/Library/PythonInstall/Scripts")); |
|
|
|
var packagesPath = Path.GetFullPath(project.Replace("/Assets", "/Library/PythonInstall/Scripts")); |
|
|
|
var packagesPath = Path.GetFullPath(Application.dataPath.Replace("/Assets","/Library/PythonInstall/bin")); |
|
|
|
var packagesPath = Path.GetFullPath(project.Replace("/Assets","/Library/PythonInstall/bin")); |
|
|
|
#endif
|
|
|
|
|
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|