No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AdaptivePerformanceSubsystemDescriptor.cs 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using UnityEngine.Scripting;
  3. using System.Collections.Generic;
  4. using UnityEngine.SubsystemsImplementation;
  5. [assembly: AlwaysLinkAssembly]
  6. namespace UnityEngine.AdaptivePerformance.Provider
  7. {
  8. [Preserve]
  9. internal static class AdaptivePerformanceSubsystemRegistry
  10. {
  11. /// <summary>
  12. /// Only for internal use.
  13. /// </summary>
  14. /// <param name="cinfo"></param>
  15. /// <returns></returns>
  16. public static AdaptivePerformanceSubsystemDescriptor RegisterDescriptor(AdaptivePerformanceSubsystemDescriptor.Cinfo cinfo)
  17. {
  18. var desc = new AdaptivePerformanceSubsystemDescriptor(cinfo);
  19. SubsystemDescriptorStore.RegisterDescriptor(desc);
  20. return desc;
  21. }
  22. /// <summary>
  23. /// Only for internal use.
  24. /// </summary>
  25. /// <returns></returns>
  26. public static List<AdaptivePerformanceSubsystemDescriptor> GetRegisteredDescriptors()
  27. {
  28. var perfDescriptors = new List<AdaptivePerformanceSubsystemDescriptor>();
  29. SubsystemManager.GetSubsystemDescriptors(perfDescriptors);
  30. return perfDescriptors;
  31. }
  32. }
  33. /// <summary>
  34. /// The Adaptive Performance Subsystem Descriptor is used for describing the subsystem so it can be picked up by the subsystem management system.
  35. /// </summary>
  36. [Preserve]
  37. public sealed class AdaptivePerformanceSubsystemDescriptor : SubsystemDescriptorWithProvider<AdaptivePerformanceSubsystem, AdaptivePerformanceSubsystem.APProvider>
  38. {
  39. /// <summary>
  40. /// Cinfo stores the ID and subsystem implementation type which is used to identify the subsystem during subsystem initialization.
  41. /// </summary>
  42. public struct Cinfo
  43. {
  44. /// <summary>
  45. /// The ID stores the name of the subsystem used to identify it in the subsystem registry.
  46. /// </summary>
  47. public string id { get; set; }
  48. /// <summary>
  49. /// Specifies the provider implementation type to use for instantiation.
  50. /// </summary>
  51. /// <value>
  52. /// The provider implementation type to use for instantiation.
  53. /// </value>
  54. public Type providerType { get; set; }
  55. /// <summary>
  56. /// Specifies the <c>AdaptivePerformanceSubsystem</c>-derived type that forwards casted calls to its provider.
  57. /// </summary>
  58. /// <value>
  59. /// The type of the subsystem to use for instantiation. If null, <c>Subsystem</c> will be instantiated.
  60. /// </value>
  61. public Type subsystemTypeOverride { get; set; }
  62. /// <summary>
  63. /// The subsystem implementation type stores the the type used for initialization in the subsystem registry.
  64. /// </summary>
  65. [Obsolete("AdaptivePerformanceSubsystem no longer supports the deprecated set of base classes for subsystems as of Unity 2023.1. Use providerType and, optionally, subsystemTypeOverride instead.", true)]
  66. public Type subsystemImplementationType { get; set; }
  67. }
  68. /// <summary>
  69. /// Constructor to fill the subsystem descriptor with all information to register the subsystem successfully.
  70. /// </summary>
  71. /// <param name="cinfo">Pass in the information about the subsystem.</param>
  72. public AdaptivePerformanceSubsystemDescriptor(Cinfo cinfo)
  73. {
  74. id = cinfo.id;
  75. providerType = cinfo.providerType;
  76. subsystemTypeOverride = cinfo.subsystemTypeOverride;
  77. }
  78. /// <summary>
  79. /// Register the subsystem with the subsystem registry and make it available to use during runtime.
  80. /// </summary>
  81. /// <param name="cinfo">Pass in the information about the subsystem.</param>
  82. /// <returns>Returns an active subsystem descriptor.</returns>
  83. public static AdaptivePerformanceSubsystemDescriptor RegisterDescriptor(Cinfo cinfo)
  84. {
  85. return AdaptivePerformanceSubsystemRegistry.RegisterDescriptor(cinfo);
  86. }
  87. }
  88. }