ImportOptions.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. using System.Runtime.InteropServices;
  6. using BansheeEngine;
  7. namespace BansheeEditor
  8. {
  9. /** @addtogroup Library
  10. * @{
  11. */
  12. /// <summary>
  13. /// Base class for all import options. Allows control over how is a specific resource type imported.
  14. /// </summary>
  15. public class ImportOptions : ScriptObject
  16. {
  17. }
  18. /// <summary>
  19. /// Determines the type of the source image for generating cubemaps.
  20. /// </summary>
  21. public enum CubemapSourceType
  22. {
  23. /// <summary>
  24. /// Source is a single image that will be replicated on all cubemap faces.
  25. /// </summary>
  26. Single,
  27. /// <summary>
  28. /// Source is a list of 6 images, either sequentially next to each other or in a cross format. The system will
  29. /// automatically guess the layout and orientation based on the aspect ratio.
  30. /// </summary>
  31. Faces,
  32. /// <summary>
  33. /// Source is a single spherical panoramic image.
  34. /// </summary>
  35. Spherical,
  36. /// <summary>
  37. /// Source is a single cylindrical panoramic image.
  38. /// </summary>
  39. Cylindrical
  40. };
  41. /// <summary>
  42. /// Provides options for controlling how is a texture resource imported.
  43. /// </summary>
  44. public class TextureImportOptions : ImportOptions
  45. {
  46. /// <summary>
  47. /// Creates new texture import options with default values.
  48. /// </summary>
  49. public TextureImportOptions()
  50. {
  51. Internal_CreateInstance(this);
  52. }
  53. /// <summary>
  54. /// Pixel format to import as.
  55. /// </summary>
  56. public PixelFormat Format
  57. {
  58. get { return Internal_GetPixelFormat(mCachedPtr); }
  59. set { Internal_SetPixelFormat(mCachedPtr, value); }
  60. }
  61. /// <summary>
  62. /// Determines whether the imported texture will have mipmaps generated.
  63. /// </summary>
  64. public bool GenerateMipmaps
  65. {
  66. get { return Internal_GetGenerateMipmaps(mCachedPtr); }
  67. set { Internal_SetGenerateMipmaps(mCachedPtr, value); }
  68. }
  69. /// <summary>
  70. /// Maximum mipmap level to generate, if mipmap generation is enabled.
  71. /// </summary>
  72. public int MaxMipmapLevel
  73. {
  74. get { return Internal_GetMaxMipmapLevel(mCachedPtr); }
  75. set { Internal_SetMaxMipmapLevel(mCachedPtr, value); }
  76. }
  77. /// <summary>
  78. /// Determines whether the texture data is also stored in main memory, available for fast CPU access.
  79. /// </summary>
  80. public bool CPUCached
  81. {
  82. get { return Internal_GetCPUCached(mCachedPtr); }
  83. set { Internal_SetCPUCached(mCachedPtr, value); }
  84. }
  85. /// <summary>
  86. /// Determines should the texture data be treated as if its in sRGB (gamma) space. Such texture will be converted by
  87. /// hardware to linear space before use on the GPU.
  88. /// </summary>
  89. public bool IsSRGB
  90. {
  91. get { return Internal_GetIsSRGB(mCachedPtr); }
  92. set { Internal_SetIsSRGB(mCachedPtr, value); }
  93. }
  94. /// <summary>
  95. /// Determines should the texture be imported as a cubemap. See <see cref="CubemapSourceType"/> to choose how will
  96. /// the source texture be converted to a cubemap.
  97. /// </summary>
  98. public bool IsCubemap
  99. {
  100. get { return Internal_GetIsCubemap(mCachedPtr); }
  101. set { Internal_SetIsCubemap(mCachedPtr, value); }
  102. }
  103. /// <summary>
  104. /// Sets a value that determines how should the source texture be interpreted when generating a cubemap. Only
  105. /// relevant when <see cref="IsCubemap"/> is set to true.
  106. /// </summary>
  107. public CubemapSourceType CubemapSourceType
  108. {
  109. get { return Internal_GetCubemapSourceType(mCachedPtr); }
  110. set { Internal_SetCubemapSourceType(mCachedPtr, value); }
  111. }
  112. [MethodImpl(MethodImplOptions.InternalCall)]
  113. private static extern void Internal_CreateInstance(TextureImportOptions instance);
  114. [MethodImpl(MethodImplOptions.InternalCall)]
  115. private static extern PixelFormat Internal_GetPixelFormat(IntPtr thisPtr);
  116. [MethodImpl(MethodImplOptions.InternalCall)]
  117. private static extern void Internal_SetPixelFormat(IntPtr thisPtr, PixelFormat value);
  118. [MethodImpl(MethodImplOptions.InternalCall)]
  119. private static extern bool Internal_GetGenerateMipmaps(IntPtr thisPtr);
  120. [MethodImpl(MethodImplOptions.InternalCall)]
  121. private static extern void Internal_SetGenerateMipmaps(IntPtr thisPtr, bool value);
  122. [MethodImpl(MethodImplOptions.InternalCall)]
  123. private static extern int Internal_GetMaxMipmapLevel(IntPtr thisPtr);
  124. [MethodImpl(MethodImplOptions.InternalCall)]
  125. private static extern void Internal_SetMaxMipmapLevel(IntPtr thisPtr, int value);
  126. [MethodImpl(MethodImplOptions.InternalCall)]
  127. private static extern bool Internal_GetCPUCached(IntPtr thisPtr);
  128. [MethodImpl(MethodImplOptions.InternalCall)]
  129. private static extern void Internal_SetCPUCached(IntPtr thisPtr, bool value);
  130. [MethodImpl(MethodImplOptions.InternalCall)]
  131. private static extern bool Internal_GetIsSRGB(IntPtr thisPtr);
  132. [MethodImpl(MethodImplOptions.InternalCall)]
  133. private static extern void Internal_SetIsSRGB(IntPtr thisPtr, bool value);
  134. [MethodImpl(MethodImplOptions.InternalCall)]
  135. private static extern bool Internal_GetIsCubemap(IntPtr thisPtr);
  136. [MethodImpl(MethodImplOptions.InternalCall)]
  137. private static extern void Internal_SetIsCubemap(IntPtr thisPtr, bool value);
  138. [MethodImpl(MethodImplOptions.InternalCall)]
  139. private static extern CubemapSourceType Internal_GetCubemapSourceType(IntPtr thisPtr);
  140. [MethodImpl(MethodImplOptions.InternalCall)]
  141. private static extern void Internal_SetCubemapSourceType(IntPtr thisPtr, CubemapSourceType value);
  142. }
  143. /// <summary>
  144. /// Information about how to split an AnimationClip into multiple separate clips.
  145. /// </summary>
  146. public class AnimationSplitInfo
  147. {
  148. public AnimationSplitInfo() { }
  149. public AnimationSplitInfo(string name, int startFrame, int endFrame, bool isAdditive)
  150. {
  151. this.name = name;
  152. this.startFrame = startFrame;
  153. this.endFrame = endFrame;
  154. this.isAdditive = isAdditive;
  155. }
  156. public string name;
  157. public int startFrame = 0;
  158. public int endFrame = 0;
  159. public bool isAdditive = false;
  160. }
  161. /// <summary>
  162. /// A set of animation events that will be added to an animation clip during animation import.
  163. /// </summary>
  164. public class ImportedAnimationEvents
  165. {
  166. public string name;
  167. public AnimationEvent[] events;
  168. }
  169. /// <summary>
  170. /// Provides options for controlling how is a mesh resource imported.
  171. /// </summary>
  172. public class MeshImportOptions : ImportOptions
  173. {
  174. /// <summary>
  175. /// Creates new mesh import options with default values.
  176. /// </summary>
  177. public MeshImportOptions()
  178. {
  179. Internal_CreateInstance(this);
  180. }
  181. /// <summary>
  182. /// Determines whether the mesh data is also stored in main memory, available for fast CPU access.
  183. /// </summary>
  184. public bool CPUCached
  185. {
  186. get { return Internal_GetCPUCached(mCachedPtr); }
  187. set { Internal_SetCPUCached(mCachedPtr, value); }
  188. }
  189. /// <summary>
  190. /// Controls should mesh normals be imported if available.
  191. /// </summary>
  192. public bool ImportNormals
  193. {
  194. get { return Internal_GetImportNormals(mCachedPtr); }
  195. set { Internal_SetImportNormals(mCachedPtr, value); }
  196. }
  197. /// <summary>
  198. /// Controls should mesh tangents/bitangents be imported if available.
  199. /// </summary>
  200. public bool ImportTangents
  201. {
  202. get { return Internal_GetImportTangents(mCachedPtr); }
  203. set { Internal_SetImportTangents(mCachedPtr, value); }
  204. }
  205. /// <summary>
  206. /// Controls should mesh skin data like bone weights, indices and bind poses be imported if available.
  207. /// </summary>
  208. public bool ImportSkin
  209. {
  210. get { return Internal_GetImportSkin(mCachedPtr); }
  211. set { Internal_SetImportSkin(mCachedPtr, value); }
  212. }
  213. /// <summary>
  214. /// Controls should animation clips be imported if available.
  215. /// </summary>
  216. public bool ImportAnimation
  217. {
  218. get { return Internal_GetImportAnimation(mCachedPtr); }
  219. set { Internal_SetImportAnimation(mCachedPtr, value); }
  220. }
  221. /// <summary>
  222. /// Controls should mesh blend shapes be imported if available.
  223. /// </summary>
  224. public bool ImportBlendShapes
  225. {
  226. get { return Internal_GetImportBlendShapes(mCachedPtr); }
  227. set { Internal_SetImportBlendShapes(mCachedPtr, value); }
  228. }
  229. /// <summary>
  230. /// Uniformly scales the imported mesh by the specified value.
  231. /// </summary>
  232. public float Scale
  233. {
  234. get { return Internal_GetScale(mCachedPtr); }
  235. set { Internal_SetScale(mCachedPtr, value); }
  236. }
  237. /// <summary>
  238. /// Determines if keyframe reduction is enabled. Keyframe reduction will reduce the number of key-frames in an
  239. /// animation clip by removing identical keyframes, and therefore reducing the size of the clip.
  240. /// </summary>
  241. public bool KeyframeReduction
  242. {
  243. get { return Internal_GetKeyFrameReduction(mCachedPtr); }
  244. set { Internal_SetKeyFrameReduction(mCachedPtr, value); }
  245. }
  246. /// <summary>
  247. /// Determines if import of root motion curves is enabled. When enabled, any animation curves in imported animations
  248. /// affecting the root bone will be available through a set of separate curves in AnimationClip, and they won't be
  249. /// evaluated through normal animation process. Instead it is expected that the user evaluates the curves manually
  250. /// and applies them as required.
  251. /// </summary>
  252. public bool ImportRootMotion
  253. {
  254. get { return Internal_GetRootMotion(mCachedPtr); }
  255. set { Internal_SetRootMotion(mCachedPtr, value); }
  256. }
  257. /// <summary>
  258. /// Controls what type (if any) of collision mesh should be imported.
  259. /// </summary>
  260. public CollisionMeshType CollisionMeshType
  261. {
  262. get { return (CollisionMeshType)Internal_GetCollisionMeshType(mCachedPtr); }
  263. set { Internal_SetCollisionMeshType(mCachedPtr, (int)value); }
  264. }
  265. /// <summary>
  266. /// Split information that allows you to split the animation clip contained in the mesh file into multiple separate
  267. /// clips. The split always applies to the first clip in the file (if the file contains multiple), other clips are
  268. /// imported as is.
  269. /// </summary>
  270. public AnimationSplitInfo[] AnimationClipSplits
  271. {
  272. get { return Internal_GetAnimationClipSplits(mCachedPtr); }
  273. set { Internal_SetAnimationClipSplits(mCachedPtr, value); }
  274. }
  275. /// <summary>
  276. /// A set of events that will be added to the animation clip, if animation import is enabled.
  277. /// </summary>
  278. public ImportedAnimationEvents[] AnimationEvents
  279. {
  280. get { return Internal_GetAnimationEvents(mCachedPtr); }
  281. set { Internal_SetAnimationEvents(mCachedPtr, value); }
  282. }
  283. [MethodImpl(MethodImplOptions.InternalCall)]
  284. private static extern void Internal_CreateInstance(MeshImportOptions instance);
  285. [MethodImpl(MethodImplOptions.InternalCall)]
  286. private static extern bool Internal_GetCPUCached(IntPtr thisPtr);
  287. [MethodImpl(MethodImplOptions.InternalCall)]
  288. private static extern void Internal_SetCPUCached(IntPtr thisPtr, bool value);
  289. [MethodImpl(MethodImplOptions.InternalCall)]
  290. private static extern bool Internal_GetImportNormals(IntPtr thisPtr);
  291. [MethodImpl(MethodImplOptions.InternalCall)]
  292. private static extern void Internal_SetImportNormals(IntPtr thisPtr, bool value);
  293. [MethodImpl(MethodImplOptions.InternalCall)]
  294. private static extern bool Internal_GetImportTangents(IntPtr thisPtr);
  295. [MethodImpl(MethodImplOptions.InternalCall)]
  296. private static extern void Internal_SetImportTangents(IntPtr thisPtr, bool value);
  297. [MethodImpl(MethodImplOptions.InternalCall)]
  298. private static extern bool Internal_GetImportSkin(IntPtr thisPtr);
  299. [MethodImpl(MethodImplOptions.InternalCall)]
  300. private static extern void Internal_SetImportSkin(IntPtr thisPtr, bool value);
  301. [MethodImpl(MethodImplOptions.InternalCall)]
  302. private static extern bool Internal_GetImportAnimation(IntPtr thisPtr);
  303. [MethodImpl(MethodImplOptions.InternalCall)]
  304. private static extern void Internal_SetImportAnimation(IntPtr thisPtr, bool value);
  305. [MethodImpl(MethodImplOptions.InternalCall)]
  306. private static extern bool Internal_GetImportBlendShapes(IntPtr thisPtr);
  307. [MethodImpl(MethodImplOptions.InternalCall)]
  308. private static extern void Internal_SetImportBlendShapes(IntPtr thisPtr, bool value);
  309. [MethodImpl(MethodImplOptions.InternalCall)]
  310. private static extern bool Internal_GetKeyFrameReduction(IntPtr thisPtr);
  311. [MethodImpl(MethodImplOptions.InternalCall)]
  312. private static extern void Internal_SetKeyFrameReduction(IntPtr thisPtr, bool value);
  313. [MethodImpl(MethodImplOptions.InternalCall)]
  314. private static extern bool Internal_GetRootMotion(IntPtr thisPtr);
  315. [MethodImpl(MethodImplOptions.InternalCall)]
  316. private static extern void Internal_SetRootMotion(IntPtr thisPtr, bool value);
  317. [MethodImpl(MethodImplOptions.InternalCall)]
  318. private static extern AnimationSplitInfo[] Internal_GetAnimationClipSplits(IntPtr thisPtr);
  319. [MethodImpl(MethodImplOptions.InternalCall)]
  320. private static extern void Internal_SetAnimationClipSplits(IntPtr thisPtr, AnimationSplitInfo[] value);
  321. [MethodImpl(MethodImplOptions.InternalCall)]
  322. private static extern ImportedAnimationEvents[] Internal_GetAnimationEvents(IntPtr thisPtr);
  323. [MethodImpl(MethodImplOptions.InternalCall)]
  324. private static extern void Internal_SetAnimationEvents(IntPtr thisPtr, ImportedAnimationEvents[] value);
  325. [MethodImpl(MethodImplOptions.InternalCall)]
  326. private static extern float Internal_GetScale(IntPtr thisPtr);
  327. [MethodImpl(MethodImplOptions.InternalCall)]
  328. private static extern void Internal_SetScale(IntPtr thisPtr, float value);
  329. [MethodImpl(MethodImplOptions.InternalCall)]
  330. private static extern int Internal_GetCollisionMeshType(IntPtr thisPtr);
  331. [MethodImpl(MethodImplOptions.InternalCall)]
  332. private static extern void Internal_SetCollisionMeshType(IntPtr thisPtr, int value);
  333. }
  334. /// <summary>
  335. /// Controls what type of collision mesh should be imported during mesh import.
  336. /// </summary>
  337. public enum CollisionMeshType // Note: Must match C++ enum CollisionMeshImport
  338. {
  339. /// <summary>
  340. /// No collision mesh will be imported.
  341. /// </summary>
  342. None,
  343. /// <summary>
  344. /// Normal triangle mesh will be imported.
  345. /// </summary>
  346. Normal,
  347. /// <summary>
  348. /// A convex hull will be generated from the source mesh.
  349. /// </summary>
  350. Convex
  351. }
  352. /// <summary>
  353. /// Marks a range of characters in a font.
  354. /// </summary>
  355. [StructLayout(LayoutKind.Sequential), SerializeObject]
  356. public struct CharRange
  357. {
  358. public int start;
  359. public int end;
  360. }
  361. /// <summary>
  362. /// Import options that provide various options for controlling how is a font resource imported.
  363. /// </summary>
  364. public class FontImportOptions : ImportOptions
  365. {
  366. /// <summary>
  367. /// Creates new font import options with default values.
  368. /// </summary>
  369. public FontImportOptions()
  370. {
  371. Internal_CreateInstance(this);
  372. }
  373. /// <summary>
  374. /// Font sizes in points that are to be imported.
  375. /// </summary>
  376. public int[] FontSizes
  377. {
  378. get { return Internal_GetFontSizes(mCachedPtr); }
  379. set { Internal_SetFontSizes(mCachedPtr, value); }
  380. }
  381. /// <summary>
  382. /// Dots per inch resolution to use when rendering the characters into the texture.
  383. /// </summary>
  384. public int DPI
  385. {
  386. get { return Internal_GetDPI(mCachedPtr); }
  387. set { Internal_SetDPI(mCachedPtr, value); }
  388. }
  389. /// <summary>
  390. /// Determines rendering mode used when rendering the characters into the bitmap.
  391. /// </summary>
  392. public FontRenderMode RenderMode
  393. {
  394. get { return Internal_GetRenderMode(mCachedPtr); }
  395. set { Internal_SetRenderMode(mCachedPtr, value); }
  396. }
  397. /// <summary>
  398. /// Determines should the characters be rendered in bold style.
  399. /// </summary>
  400. public bool Bold
  401. {
  402. get { return Internal_GetBold(mCachedPtr); }
  403. set { Internal_SetBold(mCachedPtr, value); }
  404. }
  405. /// <summary>
  406. /// Determines should the characters be rendered in italic style.
  407. /// </summary>
  408. public bool Italic
  409. {
  410. get { return Internal_GetItalic(mCachedPtr); }
  411. set { Internal_SetItalic(mCachedPtr, value); }
  412. }
  413. /// <summary>
  414. /// Determines character ranges to import from the font. Ranges are defined as unicode numbers.
  415. /// </summary>
  416. public CharRange[] CharRanges
  417. {
  418. get { return Internal_GetCharRanges(mCachedPtr); }
  419. set { Internal_SetCharRanges(mCachedPtr, value); }
  420. }
  421. [MethodImpl(MethodImplOptions.InternalCall)]
  422. private static extern void Internal_CreateInstance(FontImportOptions instance);
  423. [MethodImpl(MethodImplOptions.InternalCall)]
  424. private static extern int[] Internal_GetFontSizes(IntPtr thisPtr);
  425. [MethodImpl(MethodImplOptions.InternalCall)]
  426. private static extern void Internal_SetFontSizes(IntPtr thisPtr, int[] value);
  427. [MethodImpl(MethodImplOptions.InternalCall)]
  428. private static extern int Internal_GetDPI(IntPtr thisPtr);
  429. [MethodImpl(MethodImplOptions.InternalCall)]
  430. private static extern void Internal_SetDPI(IntPtr thisPtr, int value);
  431. [MethodImpl(MethodImplOptions.InternalCall)]
  432. private static extern FontRenderMode Internal_GetRenderMode(IntPtr thisPtr);
  433. [MethodImpl(MethodImplOptions.InternalCall)]
  434. private static extern void Internal_SetRenderMode(IntPtr thisPtr, FontRenderMode value);
  435. [MethodImpl(MethodImplOptions.InternalCall)]
  436. private static extern bool Internal_GetBold(IntPtr thisPtr);
  437. [MethodImpl(MethodImplOptions.InternalCall)]
  438. private static extern void Internal_SetBold(IntPtr thisPtr, bool value);
  439. [MethodImpl(MethodImplOptions.InternalCall)]
  440. private static extern bool Internal_GetItalic(IntPtr thisPtr);
  441. [MethodImpl(MethodImplOptions.InternalCall)]
  442. private static extern void Internal_SetItalic(IntPtr thisPtr, bool value);
  443. [MethodImpl(MethodImplOptions.InternalCall)]
  444. private static extern CharRange[] Internal_GetCharRanges(IntPtr thisPtr);
  445. [MethodImpl(MethodImplOptions.InternalCall)]
  446. private static extern void Internal_SetCharRanges(IntPtr thisPtr, CharRange[] value);
  447. }
  448. /// <summary>
  449. /// Provides various options for controlling how is a script file imported.
  450. /// </summary>
  451. public class ScriptCodeImportOptions : ImportOptions
  452. {
  453. /// <summary>
  454. /// Creates new script import options with default values.
  455. /// </summary>
  456. public ScriptCodeImportOptions()
  457. {
  458. Internal_CreateInstance(this);
  459. }
  460. /// <summary>
  461. /// Determines whether the script is editor-only or a normal game script. Editor scripts are compiled in a separate
  462. /// assembly and may reference editor specific functionality, but are not available in the final game code.
  463. /// </summary>
  464. public bool EditorScript
  465. {
  466. get { return Internal_IsEditorScript(mCachedPtr); }
  467. set { Internal_SetEditorScript(mCachedPtr, value); }
  468. }
  469. [MethodImpl(MethodImplOptions.InternalCall)]
  470. private static extern void Internal_CreateInstance(ScriptCodeImportOptions instance);
  471. [MethodImpl(MethodImplOptions.InternalCall)]
  472. private static extern bool Internal_IsEditorScript(IntPtr thisPtr);
  473. [MethodImpl(MethodImplOptions.InternalCall)]
  474. private static extern void Internal_SetEditorScript(IntPtr thisPtr, bool value);
  475. }
  476. /// <summary>
  477. /// Determines how is a font rendered into the bitmap texture.
  478. /// </summary>
  479. public enum FontRenderMode // Note: Must match C++ enum FontRenderMode
  480. {
  481. /// <summary>Render antialiased fonts without hinting (slightly more blurry).</summary>
  482. Smooth,
  483. /// <summary>Render non-antialiased fonts without hinting (slightly more blurry).</summary>
  484. Raster,
  485. /// <summary>Render antialiased fonts with hinting.</summary>
  486. HintedSmooth,
  487. /// <summary>Render non-antialiased fonts with hinting.</summary>
  488. HintedRaster
  489. }
  490. /// <summary>
  491. /// Numbers of bits per audio sample.
  492. /// </summary>
  493. public enum AudioBitDepth
  494. {
  495. Bits8 = 8,
  496. Bits16 = 16,
  497. Bits24 = 24,
  498. Bits32 = 32
  499. }
  500. /// <summary>
  501. /// Provides various options for controlling how is an audio clip file imported.
  502. /// </summary>
  503. public class AudioClipImportOptions : ImportOptions
  504. {
  505. /// <summary>
  506. /// Creates new audio clip import options with default values.
  507. /// </summary>
  508. public AudioClipImportOptions()
  509. {
  510. Internal_CreateInstance(this);
  511. }
  512. /// <summary>
  513. /// Format to import the audio clip as.
  514. /// </summary>
  515. public AudioFormat Format
  516. {
  517. get { return Internal_GetFormat(mCachedPtr); }
  518. set { Internal_SetFormat(mCachedPtr, value); }
  519. }
  520. /// <summary>
  521. /// Determines how is audio data loaded into memory.
  522. /// </summary>
  523. public AudioReadMode ReadMode
  524. {
  525. get { return Internal_GetReadMode(mCachedPtr); }
  526. set { Internal_SetReadMode(mCachedPtr, value); }
  527. }
  528. /// <summary>
  529. /// Determines will the clip be played as spatial (3D) audio or as normal audio.
  530. /// </summary>
  531. public bool Is3D
  532. {
  533. get { return Internal_GetIs3D(mCachedPtr); }
  534. set { Internal_SetIs3D(mCachedPtr, value); }
  535. }
  536. /// <summary>
  537. /// Size of a single sample in bits.
  538. /// </summary>
  539. public AudioBitDepth BitDepth
  540. {
  541. get
  542. {
  543. int bits = Internal_GetBitDepth(mCachedPtr);
  544. switch (bits)
  545. {
  546. case 8:
  547. return AudioBitDepth.Bits8;
  548. case 16:
  549. return AudioBitDepth.Bits16;
  550. case 24:
  551. return AudioBitDepth.Bits24;
  552. case 32:
  553. return AudioBitDepth.Bits32;
  554. }
  555. return AudioBitDepth.Bits16;
  556. }
  557. set { Internal_SetBitDepth(mCachedPtr, (int)value); }
  558. }
  559. [MethodImpl(MethodImplOptions.InternalCall)]
  560. private static extern void Internal_CreateInstance(AudioClipImportOptions instance);
  561. [MethodImpl(MethodImplOptions.InternalCall)]
  562. private static extern AudioFormat Internal_GetFormat(IntPtr thisPtr);
  563. [MethodImpl(MethodImplOptions.InternalCall)]
  564. private static extern void Internal_SetFormat(IntPtr thisPtr, AudioFormat format);
  565. [MethodImpl(MethodImplOptions.InternalCall)]
  566. private static extern AudioReadMode Internal_GetReadMode(IntPtr thisPtr);
  567. [MethodImpl(MethodImplOptions.InternalCall)]
  568. private static extern void Internal_SetReadMode(IntPtr thisPtr, AudioReadMode readMode);
  569. [MethodImpl(MethodImplOptions.InternalCall)]
  570. private static extern bool Internal_GetIs3D(IntPtr thisPtr);
  571. [MethodImpl(MethodImplOptions.InternalCall)]
  572. private static extern void Internal_SetIs3D(IntPtr thisPtr, bool is3d);
  573. [MethodImpl(MethodImplOptions.InternalCall)]
  574. private static extern int Internal_GetBitDepth(IntPtr thisPtr);
  575. [MethodImpl(MethodImplOptions.InternalCall)]
  576. private static extern void Internal_SetBitDepth(IntPtr thisPtr, int bitDepth);
  577. }
  578. /** @} */
  579. }