|
|
|
|
|
|
using UnityEngine.Perception.GroundTruth; |
|
|
|
|
|
|
|
public class PyrceptionInstaller : EditorWindow |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#if UNITY_EDITOR_OSX || true
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Runs pyrception instance in default browser
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
#if UNITY_EDITOR_OSX
|
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
if (RestartBrowser()) |
|
|
|
return; |
|
|
|
#elif UNITY_EDITOR_OSX
|
|
|
|
KillProcess(); |
|
|
|
#endif
|
|
|
|
string path = Path.GetFullPath(Application.dataPath.Replace("/Assets", "")); |
|
|
|
|
|
|
int ExitCode = 0; |
|
|
|
ExecuteCMD(command, ref ExitCode, waitForExit: false, displayWindow: true); |
|
|
|
if (ExitCode != 0) |
|
|
|
{ |
|
|
|
} |
|
|
|
{ |
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
UnityEngine.Debug.Log("Launching visualization tool..."); |
|
|
|
#elif UNITY_EDITOR_OSX
|
|
|
|
#endif
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
EditorUtility.ClearProgressBar(); |
|
|
|
} |
|
|
|
|
|
|
|
#if UNITY_EDITOR_OSX || true
|
|
|
|
void OnDestroy() |
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
private static bool RestartBrowser() |
|
|
|
KillProcess(); |
|
|
|
if (currentProcessId != -1) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
Process proc = Process.GetProcessById(currentProcessId + 1); |
|
|
|
Process.Start("http://localhost:8501"); |
|
|
|
return true; |
|
|
|
} |
|
|
|
catch(System.Exception e) |
|
|
|
{ |
|
|
|
currentProcessId = -1; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
|
|
|
|
#elif UNITY_EDITOR_OSX || true
|
|
|
|
|
|
|
|
private static void KillProcess() |
|
|
|
{ |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void Quit() |
|
|
|
{ |
|
|
|
KillProcess(); |
|
|
|
} |
|
|
|
|
|
|
|
[RuntimeInitializeOnLoadMethod] |
|
|
|
static void RunOnStart() |
|
|
|
{ |
|
|
|
Application.quitting += Quit; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Executes command in cmd or console depending on system
|
|
|
|
|
|
|
|
|
|
|
if (!waitForExit) |
|
|
|
{ |
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
if (currentProcessId == -1) |
|
|
|
currentProcessId = cmd.Id; |
|
|
|
#elif UNITY_EDITOR_OSX
|
|
|
|
return ""; |
|
|
|
#endif
|
|
|
|
return output; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|