private static SpeechProxyConfig GetSpeechProxyConfig() { SetupAppDataFolder(); string path = GetAppConfig(); SpeechProxyConfig speechProxyConfig = null; try { if (File.Exists(path)) { using (FileStream fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (StreamReader sr = new StreamReader(fs)) { string jsonData = sr.ReadToEnd(); //Debug.Log(jsonData); speechProxyConfig = JsonUtility.FromJson <SpeechProxyConfig>(jsonData); } } } } catch (Exception) { } if (null == speechProxyConfig) { speechProxyConfig = new SpeechProxyConfig(); } return(speechProxyConfig); }
public void ManagementLaunchProxy() { _mPendingCommands.Insert(0, "ClearPendingCommands"); #if (UNITY_EDITOR || UNITY_STANDALONE) && !UNITY_WEBPLAYER string path = GetAppDataFolder(); if (!Directory.Exists(path)) { Debug.LogError("The Speech Proxy needs to run once to set the install path!"); return; } //Debug.LogFormat("Data folder: {0}", path); SpeechProxyConfig speechProxyConfig = GetSpeechProxyConfig(); //Debug.LogFormat("AppName: {0}", speechProxyConfig.appName); //Debug.LogFormat("InstallDirectory: {0}", speechProxyConfig.installDirectory); //Debug.LogFormat("ProxyPort: {0}", speechProxyConfig.proxyPort); #endif #if (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN) && !UNITY_WEBPLAYER const string APP_CMD = @"C:\Windows\System32\cmd.exe"; try { Process process = new Process(); StringBuilder args = new StringBuilder(); args.AppendFormat("/c start \"\" \"{0}\\{1}\" {2}", speechProxyConfig.installDirectory, speechProxyConfig.appName, _mPort); //Debug.Log(args.ToString()); process.StartInfo = new ProcessStartInfo(APP_CMD, args.ToString()); process.StartInfo.WorkingDirectory = speechProxyConfig.installDirectory; process.Exited += (sender, e) => { process.Dispose(); }; process.Start(); } catch (Exception) { } #elif (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX) && !UNITY_WEBPLAYER const string APP_MONO_PATH = "/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono"; try { Process process = new Process(); string launch = string.Format("{0}/{1}", speechProxyConfig.installDirectory, speechProxyConfig.appName); ProcessStartInfo psi = new ProcessStartInfo(APP_MONO_PATH, launch); psi.WorkingDirectory = speechProxyConfig.installDirectory; process.StartInfo = psi; process.Exited += (sender, e) => { //Debug.LogFormat("Process exited."); process.Dispose(); }; //Debug.LogFormat("Launch: {0} {1}", APP_BASH_MAC, args); process.Start(); } catch (Exception) { } #endif }