XRLoader.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.Rendering;
  4. namespace UnityEngine.XR.Management
  5. {
  6. /// <summary>
  7. /// XR Loader abstract class used as a base class for specific provider implementations. Providers should implement
  8. /// subclasses of this to provide specific initialization and management implementations that make sense for their supported
  9. /// scenarios and needs.
  10. /// </summary>
  11. public abstract class XRLoader : ScriptableObject
  12. {
  13. /// <summary>
  14. /// Initialize the loader. This should initialize all subsystems to support the desired runtime setup this
  15. /// loader represents.
  16. ///
  17. /// This is the only method on XRLoader that Management uses to determine the active loader to use. If this
  18. /// method returns true, Management locks this loader as the <see cref="XRManagerSettings.activeLoader"/>
  19. /// and and stops fall through processing on the <see cref="XRManagerSettings.loaders"/> list of current loaders.
  20. ///
  21. /// If this method returns false, <see cref="XRManagerSettings"/> continues to process the next loader
  22. /// in the <see cref="XRManagerSettings.loaders"/> list, or fails completely when the list is exhausted.
  23. /// </summary>
  24. ///
  25. /// <returns>Whether or not initialization succeeded.</returns>
  26. public virtual bool Initialize() { return true; }
  27. /// <summary>
  28. /// Ask loader to start all initialized subsystems.
  29. /// </summary>
  30. ///
  31. /// <returns>Whether or not all subsystems were successfully started.</returns>
  32. public virtual bool Start() { return true; }
  33. /// <summary>
  34. /// Ask loader to stop all initialized subsystems.
  35. /// </summary>
  36. ///
  37. /// <returns>Whether or not all subsystems were successfully stopped.</returns>
  38. public virtual bool Stop() { return true; }
  39. /// <summary>
  40. /// Ask loader to deinitialize all initialized subsystems.
  41. /// </summary>
  42. ///
  43. /// <returns>Whether or not deinitialization succeeded.</returns>
  44. public virtual bool Deinitialize() { return true; }
  45. /// <summary>
  46. /// Gets the loaded subsystem of the specified type. Implementation dependent as only implemetnations
  47. /// know what they have loaded and how best to get it..
  48. /// </summary>
  49. ///
  50. /// <typeparam name="T">Type of the subsystem to get</typeparam>
  51. ///
  52. /// <returns>The loaded subsystem or null if not found.</returns>
  53. public abstract T GetLoadedSubsystem<T>() where T : class, ISubsystem;
  54. /// <summary>
  55. /// Gets the loader's supported graphics device types. If the list is empty, it is assumed that it supports all graphics device types.
  56. /// </summary>
  57. ///
  58. /// <param name="buildingPlayer">True if the player is being built. You may want to include or exclude graphics apis if the player is being built or not.</param>
  59. /// <returns>Returns the loader's supported graphics device types.</returns>
  60. public virtual List<GraphicsDeviceType> GetSupportedGraphicsDeviceTypes(bool buildingPlayer)
  61. {
  62. return new List<GraphicsDeviceType>();
  63. }
  64. }
  65. }