SubsystemRegistration.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. using System.Collections.Generic;
  2. #if !UNITY_2019_2_OR_NEWER
  3. using UnityEngine.Experimental;
  4. #endif
  5. namespace UnityEngine
  6. {
  7. public static class SubsystemRegistration
  8. {
  9. static readonly List<SubsystemDescriptor> k_SubsystemDescriptors = new List<SubsystemDescriptor>();
  10. /// <summary>
  11. /// Registers a <c>SubsystemDescriptor</c> with the Subsystem Manager so that features and implementation type are available.
  12. /// </summary>
  13. /// <param name="descriptor"> The <c>SubsystemDescriptor</c> that describes the subsystem implementation.</param>
  14. /// <returns><c>True</c> if the descriptor does not already exist and registration happens, otherwise, <c>False</c>.</returns>
  15. public static bool CreateDescriptor(SubsystemDescriptor descriptor)
  16. {
  17. foreach (var declaration in k_SubsystemDescriptors)
  18. {
  19. if (descriptor.subsystemImplementationType == declaration.subsystemImplementationType)
  20. return false;
  21. }
  22. Internal_SubsystemDescriptors.Internal_AddDescriptor(descriptor);
  23. k_SubsystemDescriptors.Add(descriptor);
  24. return true;
  25. }
  26. }
  27. }