/// <summary> /// Call when destroyed /// </summary> private void OnDestroy() { // DESTROY GEOMETRY if (geometryHandle != IntPtr.Zero && PropIFace.DestroyAudioGeometry(geometryHandle) != OSPSuccess) { throw new Exception("Unable to destroy geometry"); } geometryHandle = IntPtr.Zero; }
//*********************************************************************** // WriteFile - Write the serialized mesh file. public bool WriteFile() { if (filePath == null || filePath.Length == 0) { Debug.Log("Invalid mesh file path"); return(false); } AudioConfiguration config = AudioSettings.GetConfiguration(); // Create a temporary geometry. IntPtr tempGeometryHandle = IntPtr.Zero; if (PropIFace.CreateAudioGeometry(out tempGeometryHandle) != OSPSuccess) { throw new Exception("Unable to create temp geometry handle"); } // Upload the mesh geometry. if (uploadMesh(tempGeometryHandle, gameObject, gameObject.transform.worldToLocalMatrix, false) != OSPSuccess) { Debug.Log("Error uploading mesh " + gameObject.name); return(false); } // Write the mesh to a file. if (PropIFace.AudioGeometryWriteMeshFile(tempGeometryHandle, filePath) != OSPSuccess) { Debug.Log("Error writing mesh file " + filePath); return(false); } // Destroy the geometry. PropIFace.DestroyAudioGeometry(tempGeometryHandle); Debug.Log("Write mesh file " + filePath); return(true); }