浏览代码

create first proof of concept for automating pyrception install and launch from Unity Editor

/pyrception-integration
leopoldo-zugasti 4 年前
当前提交
64fae025
共有 4 个文件被更改,包括 69 次插入0 次删除
  1. 8
      com.unity.perception/Editor/Pyrception.meta
  2. 50
      com.unity.perception/Editor/Pyrception/PyrceptionInstaller.cs
  3. 11
      com.unity.perception/Editor/Pyrception/PyrceptionInstaller.cs.meta

8
com.unity.perception/Editor/Pyrception.meta


fileFormatVersion: 2
guid: e717740bcfeada94dbf82a48207fced2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

50
com.unity.perception/Editor/Pyrception/PyrceptionInstaller.cs


using System.Diagnostics;
using UnityEditor;
using UnityEngine;
using UnityEngine.Perception.GroundTruth;
public class PyrceptionInstaller
{
[MenuItem("Window/General/Pyrception/Run")]
static void RunPyrception()
{
string path = Application.dataPath.Replace("/Assets","").Replace("/","\\");
string command = $"cd {path}\\DataInsightsEnv\\Scripts\\ && activate && pyrception-utils.exe preview --data=\"{PlayerPrefs.GetString(SimulationState.latestOutputDirectoryKey)}/..\"";
ProcessStartInfo info = new ProcessStartInfo("cmd.exe", "/c " + command);
info.CreateNoWindow = false;
info.UseShellExecute = true;
Process cmd = Process.Start(info);
}
[MenuItem("Window/General/Pyrception/Setup")]
static void SetupPyrception()
{
string path = Application.dataPath.Replace("/Assets", "").Replace("/", "\\");
string pyrceptionPath = "C:\\Users\\leopoldo.zugasti\\Desktop\\DatasetInsights\\Pyrception\\pyrception-utils-dev";
string command =
$"pip install virtualenv && " +
$"cd {path} && " +
$"virtualenv DataInsightsEnv && " +
$"XCOPY /E/I/Y {pyrceptionPath} .\\DataInsightsEnv\\pyrception-util && " +
$".\\DataInsightsEnv\\Scripts\\activate && " +
$"cd .\\DataInsightsEnv\\pyrception-util && " +
$"pip --no-cache-dir install -e .";
ProcessStartInfo info = new ProcessStartInfo("cmd.exe", "/c " + command);
info.CreateNoWindow = false;
info.UseShellExecute = true;
Process cmd = Process.Start(info);
cmd.WaitForExit();
int ExitCode = cmd.ExitCode;
if(ExitCode == 0)
{
UnityEngine.Debug.Log("Completed setup for Dataset Insights");
}
else
{
UnityEngine.Debug.LogError("Dataset Insights setup failed");
}
}
}

11
com.unity.perception/Editor/Pyrception/PyrceptionInstaller.cs.meta


fileFormatVersion: 2
guid: 261fc1eb441e8a94b820348e3da67776
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存