// Start recording private void OnStartRecording() { // Get root #if UNITY_EDITOR string path = Application.dataPath.Replace("\\", "/").Replace("/Assets", ""); #else string path = Application.temporaryCachePath; #endif // Add & create directory path += "/" + fileDirectory; if (path.EndsWith("/")) { path = path.Substring(0, path.Length - 1); } if (!IOUtility.CreateDirectory(path)) { Debug.LogError("MicDebug - Create Directory Failed"); return; } // Generate file name DateTime now = DateTime.Now; path = $"{path}/{fileName}{now.Year:0000}{now.Month:00}{now.Day:00}_{now.Hour:00}{now.Minute:00}{now.Second:00}.pcm"; Debug.Log("MicDebug - Writing recording to file: " + path); // Create file stream _fileStream = File.Open(path, FileMode.Create); }
/// <summary> /// Generates a manifest and optionally opens it in the editor. /// </summary> /// <param name="configuration">The configuration that we are generating the manifest for.</param> /// <param name="openManifest">If true, will open the manifest file in the code editor.</param> private static void GenerateManifest(WitConfiguration configuration, bool openManifest) { // Generate var startGenerationTime = DateTime.UtcNow; var manifest = ManifestGenerator.GenerateManifest(configuration.application.name, configuration.application.id); var endGenerationTime = DateTime.UtcNow; // Get file path string fullPath = configuration.ManifestEditorPath; if (string.IsNullOrEmpty(fullPath) || !File.Exists(fullPath)) { string directory = Application.dataPath + "/Oculus/Voice/Resources"; IOUtility.CreateDirectory(directory, true); fullPath = directory + "/" + configuration.manifestLocalPath; } // Write to file try { var writer = new StreamWriter(fullPath); writer.WriteLine(manifest); writer.Close(); } catch (Exception e) { Debug.LogError($"Wit Configuration Editor - Conduit Manifest Creation Failed\nPath: {fullPath}\n{e}"); return; } Statistics.SuccessfulGenerations++; Statistics.AddFrequencies(AssemblyMiner.SignatureFrequency); Statistics.AddIncompatibleFrequencies(AssemblyMiner.IncompatibleSignatureFrequency); var generationTime = endGenerationTime - startGenerationTime; AssetDatabase.ImportAsset(fullPath.Replace(Application.dataPath, "Assets")); Debug.Log($"Done generating manifest. Total time: {generationTime.TotalMilliseconds} ms"); if (openManifest) { UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(fullPath, 1); } }
private void SaveConfig(string applicationName, string sectionName, int major, int minor, byte[] buffer, string operatorId = "len.zhang") { MemoryStream stream = new MemoryStream(buffer); XmlDocument doc = new XmlDocument(); doc.Load(stream); doc.DocumentElement.SetAttribute("majorVersion", major.ToString()); doc.DocumentElement.SetAttribute("minorVersion", minor.ToString()); string folder = System.Configuration.ConfigurationManager.AppSettings["publishFolder"]; folder += "\\" + applicationName + "\\" + sectionName + "\\" + major + "\\"; IOUtility.CreateDirectory(folder); string fileName = folder + sectionName + "." + minor; doc.Save(fileName); AddLog(applicationName, sectionName, major, minor, operatorId); }