using System; using UnityEngine.Scripting; using System.Collections.Generic; [assembly: AlwaysLinkAssembly] namespace UnityEngine.AdaptivePerformance.Provider { using AdaptivePerformanceSubsystemDescriptorBase = UnityEngine.SubsystemDescriptor; [Preserve] internal static class AdaptivePerformanceSubsystemRegistry { /// /// Only for internal use. /// /// /// public static AdaptivePerformanceSubsystemDescriptor RegisterDescriptor(AdaptivePerformanceSubsystemDescriptor.Cinfo cinfo) { var desc = new AdaptivePerformanceSubsystemDescriptor(cinfo); if (SubsystemRegistration.CreateDescriptor(desc)) { return desc; } else { var registeredDescriptors = GetRegisteredDescriptors(); foreach (var d in registeredDescriptors) { if (d.subsystemImplementationType == cinfo.subsystemImplementationType) return d; } } return null; } /// /// Only for internal use. /// /// public static List GetRegisteredDescriptors() { var perfDescriptors = new List(); SubsystemManager.GetSubsystemDescriptors(perfDescriptors); return perfDescriptors; } } /// /// The Adaptive Performance Subsystem Descriptor is used for describing the subsystem so it can be picked up by the subsystem management system. /// #pragma warning disable CS0618 [Preserve] public sealed class AdaptivePerformanceSubsystemDescriptor : AdaptivePerformanceSubsystemDescriptorBase { /// /// Cinfo stores the ID and subsystem implementation type which is used to identify the subsystem during subsystem initialization. /// public struct Cinfo { /// /// The ID stores the name of the subsystem used to identify it in the subsystem registry. /// public string id { get; set; } /// /// The subsystem implementation type stores the the type used for initialization in the subsystem registry. /// public Type subsystemImplementationType { get; set; } } /// /// Constructor to fill the subsystem descriptor with all information to register the subsystem successfully. /// /// Pass in the information about the subsystem. public AdaptivePerformanceSubsystemDescriptor(Cinfo cinfo) { id = cinfo.id; subsystemImplementationType = cinfo.subsystemImplementationType; } /// /// Register the subsystem with the subsystem registry and make it available to use during runtime. /// /// Pass in the information about the subsystem. /// Returns an active subsystem descriptor. public static AdaptivePerformanceSubsystemDescriptor RegisterDescriptor(Cinfo cinfo) { return AdaptivePerformanceSubsystemRegistry.RegisterDescriptor(cinfo); } } #pragma warning restore CS0618 }