//==============================INSTALL VISUALIZER IN PYTHON FOR UNITY======================================
EditorUtility . DisplayProgressBar ( "Setting up the Visualizer" , "Installing the Visualizer... " , 2.5f / steps ) ;
EditorUtility . DisplayProgressBar ( "Setting up the Visualizer" , "Installing Visualizer (This may take a few minutes - this only happens once) " , 2.5f / steps ) ;
ExecuteCMD ( $"\" { packagesPath } \ "\\pip3.bat install --upgrade --no-warn-script-location unity-cv-datasetvisualizer" , ref ExitCode , ref output , waitForExit : 0 ) ;
ExecuteCMD ( $"\" { packagesPath } \ "\\pip3.bat install --upgrade --no-warn-script-location unity-cv-datasetvisualizer" , ref ExitCode , ref output , waitForExit : - 1 ) ;
ExecuteCMD ( $"cd \'{packagesPath}\'; ./python3.7 -m pip install --upgrade unity-cv-datasetvisualizer" , ref ExitCode , ref output , waitForExit : 0 ) ;
ExecuteCMD ( $"cd \'{packagesPath}\'; ./python3.7 -m pip install --upgrade unity-cv-datasetvisualizer" , ref ExitCode , ref output , waitForExit : - 1 ) ;
#endif
if ( ExitCode ! = 0 ) {
EditorUtility . ClearProgressBar ( ) ;
/// <returns></returns>
private static int ExecuteCMD ( string command , ref int ExitCode , ref string output , int waitForExit = 0 , bool displayWindow = false , bool getOutput = false )
{
UnityEngine . Debug . Log ( command ) ;
string shell = "" ;
string argument = "" ;
info . CreateNoWindow = ! displayWindow ;
info . UseShellExecute = false ;
info . RedirectStandardOutput = getOutput ;
info . RedirectStandardError = waitForExit ! = 0 ;
info . RedirectStandardError = waitForExit > 0 ;
Process cmd = Process . Start ( info ) ;
}
cmd . WaitForExit ( waitForExit ) ;
if ( waitForExit = = - 1 )
{
cmd . WaitForExit ( ) ;
}
else if ( waitForExit > 0 )
{
cmd . WaitForExit ( waitForExit ) ;
}
ExitCode = cmd . ExitCode ;
if ( ExitCode ! = 0 )
{
UnityEngine . Debug . LogError ( $"Error - {ExitCode} - Failed to execute: {command} - {cmd.StandardError.ReadToEnd()}" ) ;
if ( cmd . HasExited ) {
ExitCode = cmd . ExitCode ;
if ( ExitCode ! = 0 )
{
UnityEngine . Debug . LogError ( $"Error - {ExitCode} - Failed to execute: {command} - {cmd.StandardError.ReadToEnd()}" ) ;
}
}
cmd . Close ( ) ;