udConvert.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using UnityEngine;
  4. namespace udSDK
  5. {
  6. class udConvertContext
  7. {
  8. public IntPtr pConvertContext;
  9. public void Create(udContext context)
  10. {
  11. udError error = udConvert_CreateContext(context.pContext, ref pConvertContext);
  12. if (error != udSDK.udError.udE_Success)
  13. throw new Exception("udConvertContext.Create failed.");
  14. }
  15. public void Destroy()
  16. {
  17. udError error = udConvert_DestroyContext(ref pConvertContext);
  18. if (error != udSDK.udError.udE_Success)
  19. throw new Exception("udConvertContext.Destroy failed.");
  20. }
  21. public void AddFile(string fileName)
  22. {
  23. udError error = udConvert_AddItem(pConvertContext, fileName);
  24. if (error != udSDK.udError.udE_Success)
  25. throw new Exception("udConvertContext.AddItem failed.");
  26. }
  27. public void SetFileName(string fileName)
  28. {
  29. udError error = udConvert_SetOutputFilename(pConvertContext, fileName);
  30. if (error != udSDK.udError.udE_Success)
  31. throw new Exception("udConvertContext.SetOutputFilename failed.");
  32. }
  33. public void DoConvert()
  34. {
  35. udError error = udConvert_DoConvert(pConvertContext);
  36. if (error != udSDK.udError.udE_Success)
  37. throw new Exception("udConvertContext.DoConvert failed.");
  38. }
  39. [DllImport(UDSDKLibrary.name)]
  40. private static extern udError udConvert_CreateContext(IntPtr pContext, ref IntPtr ppConvertContext);
  41. [DllImport(UDSDKLibrary.name)]
  42. private static extern udError udConvert_DestroyContext(ref IntPtr ppConvertContext);
  43. [DllImport(UDSDKLibrary.name)]
  44. private static extern udError udConvert_AddItem(IntPtr pConvertContext, string fileName);
  45. [DllImport(UDSDKLibrary.name)]
  46. private static extern udError udConvert_SetOutputFilename(IntPtr pConvertContext, string fileName);
  47. [DllImport(UDSDKLibrary.name)]
  48. private static extern udError udConvert_DoConvert(IntPtr pConvertContext);
  49. }
  50. }