暫無描述
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.

StandaloneLoader.cs 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System.Collections.Generic;
  2. using UnityEngine.AdaptivePerformance.Provider;
  3. namespace UnityEngine.AdaptivePerformance.Tests.Standalone
  4. {
  5. public class StandaloneLoader : AdaptivePerformanceLoaderHelper
  6. {
  7. static List<AdaptivePerformanceSubsystemDescriptor> s_StandaloneSubsystemDescriptors = new List<AdaptivePerformanceSubsystemDescriptor>();
  8. public override bool Initialized
  9. {
  10. get { return standaloneSubsystem != null; }
  11. }
  12. public override bool Running
  13. {
  14. get { return standaloneSubsystem != null && standaloneSubsystem.running; }
  15. }
  16. public StandaloneSubsystem standaloneSubsystem
  17. {
  18. get
  19. {
  20. return GetLoadedSubsystem<StandaloneSubsystem>();
  21. }
  22. }
  23. public bool started { get; protected set; }
  24. public bool stopped { get; protected set; }
  25. public bool deInitialized { get; protected set; }
  26. void OnStartCalled()
  27. {
  28. started = true;
  29. }
  30. void OnStopCalled()
  31. {
  32. stopped = true;
  33. }
  34. void OnDestroyCalled()
  35. {
  36. deInitialized = true;
  37. }
  38. public override ISubsystem GetDefaultSubsystem()
  39. {
  40. return GetLoadedSubsystem<StandaloneSubsystem>();
  41. }
  42. public override IAdaptivePerformanceSettings GetSettings()
  43. {
  44. return null;
  45. }
  46. public override bool Initialize()
  47. {
  48. started = false;
  49. stopped = false;
  50. deInitialized = false;
  51. CreateSubsystem<AdaptivePerformanceSubsystemDescriptor, StandaloneSubsystem>(s_StandaloneSubsystemDescriptors, "Standalone Subsystem");
  52. if (standaloneSubsystem == null)
  53. return false;
  54. standaloneSubsystem.startCalled += OnStartCalled;
  55. standaloneSubsystem.stopCalled += OnStopCalled;
  56. standaloneSubsystem.destroyCalled += OnDestroyCalled;
  57. return true;
  58. }
  59. public override bool Start()
  60. {
  61. if (standaloneSubsystem != null)
  62. StartSubsystem<StandaloneSubsystem>();
  63. return true;
  64. }
  65. public override bool Stop()
  66. {
  67. if (standaloneSubsystem != null)
  68. StopSubsystem<StandaloneSubsystem>();
  69. return true;
  70. }
  71. public override bool Deinitialize()
  72. {
  73. DestroySubsystem<StandaloneSubsystem>();
  74. if (standaloneSubsystem != null)
  75. {
  76. standaloneSubsystem.startCalled -= OnStartCalled;
  77. standaloneSubsystem.stopCalled -= OnStopCalled;
  78. standaloneSubsystem.destroyCalled -= OnDestroyCalled;
  79. }
  80. return base.Deinitialize();
  81. }
  82. }
  83. }