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

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