示例#1
0
//----------------------------------------------------------------------------------------------------------------------

        bool SetupAutoLoadPlugin(string appPath, string startArgument)
        {
            try {
                if (!System.IO.File.Exists(appPath))
                {
                    Debug.LogError("[MeshSync] No maya installation found at " + appPath);
                    return(false);
                }

                EditorUtility.DisplayProgressBar("MeshSync", "Launching app to finalize installation", 0.75f);
                System.Diagnostics.Process process = DiagnosticsUtility.StartProcess(
                    appPath, startArgument
                    );
                process.WaitForExit();

                int exitCode = process.ExitCode;
                EditorUtility.ClearProgressBar();

                if (0 != exitCode)
                {
                    string stderr = process.StandardError.ReadToEnd();
                    Debug.LogError($"[MeshSync] 3dsMax plugin installation error. ExitCode: {exitCode}. {stderr}");
                    return(false);
                }
            } catch (Exception e) {
                Debug.LogError("[MeshSync] Failed to setup 3dsMax plugin. Exception: " + e.Message);
                return(false);
            }

            return(true);
        }
示例#2
0
//----------------------------------------------------------------------------------------------------------------------

        bool SetupAutoLoadPlugin(string appPath, string startArgument)
        {
            try {
                if (!System.IO.File.Exists(appPath))
                {
                    SetLastErrorMessage($"No 3dsMax installation found at {appPath}");
                    return(false);
                }

                EditorUtility.DisplayProgressBar("MeshSync", "Launching app to finalize installation", 0.75f);
                System.Diagnostics.Process process = DiagnosticsUtility.StartProcess(
                    appPath, startArgument
                    );
                process.WaitForExit();

                int exitCode = process.ExitCode;
                EditorUtility.ClearProgressBar();

                if (0 != exitCode)
                {
                    string stderr = process.StandardError.ReadToEnd();
                    SetLastErrorMessage($"Process error. ExitCode: {exitCode}. {stderr}");
                    return(false);
                }
            } catch (Exception e) {
                SetLastErrorMessage($"Process error. Exception: {e.Message}");
                return(false);
            }

            return(true);
        }
示例#3
0
//----------------------------------------------------------------------------------------------------------------------


        bool SetupAutoLoadPlugin(string appPath, string dccToolVersion,
                                 string uninstallScriptPath, string installScriptPath)
        {
            try {
                if (!System.IO.File.Exists(appPath))
                {
                    Debug.LogError("[MeshSync] No Blender installation found at " + appPath);
                    return(false);
                }

                //Try to uninstall first. The uninstallation may have exceptions/error messages, but they can be ignored
                System.Diagnostics.Process process = DiagnosticsUtility.StartProcess(
                    appPath,
                    $"-b -P {uninstallScriptPath}",
                    /*useShellExecute=*/ false, /*redirectStandardError=*/ true
                    );
                process.WaitForExit();


#if UNITY_EDITOR_OSX
                //Delete plugin on mac to avoid errors of loading new plugin:
                //Termination Reason: Namespace CODESIGNING, Code 0x2
                string installedPluginDir = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
                                            + $"/Library/Application Support/Blender/{dccToolVersion}/scripts/addons/MeshSyncClientBlender";
                string[] files = System.IO.Directory.GetFiles(installedPluginDir, "*.so");
                if (files.Length > 0)
                {
                    foreach (string binaryPluginFile in files)
                    {
                        try {
                            File.Delete(binaryPluginFile);
                        } catch (Exception e) {
                            Debug.LogError("[MeshSync] Error when deleting previous plugin: " + binaryPluginFile);
                        }
                    }
                }
#endif

                //Install
                const int PYTHON_EXIT_CODE = 10;
                process.StartInfo.Arguments = $"-b -P {installScriptPath} --python-exit-code {PYTHON_EXIT_CODE}";
                process.Start();
                process.WaitForExit();
                int exitCode = process.ExitCode;

                if (0 != exitCode)
                {
                    string stderr = process.StandardError.ReadToEnd();
                    Debug.LogError($"[MeshSync] Installation error. ExitCode: {exitCode}. {stderr}");
                    return(false);
                }
            } catch (Exception e) {
                Debug.LogError("[MeshSync] Failed to install plugin. Exception: " + e.Message);
                return(false);
            }

            return(true);
        }
        void OnLaunchDCCToolButtonClicked(EventBase evt)
        {
            DCCToolInfo dccToolInfo = GetEventButtonUserDataAs <DCCToolInfo>(evt.target);

            if (null == dccToolInfo || string.IsNullOrEmpty(dccToolInfo.AppPath) || !File.Exists(dccToolInfo.AppPath))
            {
                Debug.LogWarning("[MeshSync] Failed to launch DCC Tool");
                return;
            }

            DiagnosticsUtility.StartProcess(dccToolInfo.AppPath);
        }
示例#5
0
//----------------------------------------------------------------------------------------------------------------------


        bool SetupAutoLoadPlugin(string appPath, string dccToolVersion,
                                 string uninstallScriptPath, string installScriptPath)
        {
            try {
                if (!System.IO.File.Exists(appPath))
                {
                    SetLastErrorMessage("No Blender installation found at " + appPath);
                    return(false);
                }

                //Try to uninstall first. The uninstallation may have exceptions/error messages, but they can be ignored
                System.Diagnostics.Process process = DiagnosticsUtility.StartProcess(
                    appPath,
                    $"-b -P {uninstallScriptPath}",
                    /*useShellExecute=*/ false, /*redirectStandardError=*/ true
                    );
                process.WaitForExit();


#if UNITY_EDITOR_OSX
                DeleteInstalledPluginOnMac(dccToolVersion);
#endif

                //Install
                const int PYTHON_EXIT_CODE = 10;
                process.StartInfo.Arguments = $"-b -P \"{installScriptPath}\" --python-exit-code {PYTHON_EXIT_CODE}";
                process.Start();
                process.WaitForExit();
                int exitCode = process.ExitCode;

                if (0 != exitCode)
                {
                    string stderr = process.StandardError.ReadToEnd();
                    SetLastErrorMessage($"Process error. ExitCode: {exitCode}. {stderr}");
                    return(false);
                }
            } catch (Exception e) {
                SetLastErrorMessage($"Process error. Exception: {e.Message}");
                return(false);
            }

            return(true);
        }