설명 없음
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.

TestLoaderBase.cs 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System.Collections.Generic;
  2. #if UNITY_EDITOR
  3. using UnityEditor;
  4. using UnityEditor.AdaptivePerformance;
  5. using UnityEngine.AdaptivePerformance.Provider;
  6. #endif
  7. using UnityEngine.AdaptivePerformance.Tests.Standalone;
  8. namespace UnityEngine.AdaptivePerformance.TestPackage
  9. {
  10. public class TestLoaderBase : AdaptivePerformanceLoaderHelper
  11. {
  12. #if UNITY_EDITOR
  13. public TestLoaderBase()
  14. {
  15. WasAssigned = false;
  16. WasUnassigned = false;
  17. }
  18. public static bool WasAssigned { get; set; }
  19. public static bool WasUnassigned { get; set; }
  20. #endif
  21. static List<AdaptivePerformanceSubsystemDescriptor> s_StandaloneSubsystemDescriptors =
  22. new List<AdaptivePerformanceSubsystemDescriptor>();
  23. public override bool Initialized
  24. {
  25. get { return inputSubsystem != null; }
  26. }
  27. public override bool Running
  28. {
  29. get { return inputSubsystem != null && inputSubsystem.running; }
  30. }
  31. public StandaloneSubsystem inputSubsystem
  32. {
  33. get { return GetLoadedSubsystem<StandaloneSubsystem>(); }
  34. }
  35. public override ISubsystem GetDefaultSubsystem()
  36. {
  37. return GetLoadedSubsystem<StandaloneSubsystem>();
  38. }
  39. public override IAdaptivePerformanceSettings GetSettings()
  40. {
  41. TestSettings settings = null;
  42. // When running in the Unity Editor, we have to load user's customization of configuration data directly from
  43. // EditorBuildSettings. At runtime, we need to grab it from the static instance field instead.
  44. #if UNITY_EDITOR
  45. UnityEditor.EditorBuildSettings.TryGetConfigObject(Constants.k_SettingsKey, out settings);
  46. #else
  47. settings = TestSettings.s_RuntimeInstance;
  48. #endif
  49. return settings;
  50. }
  51. #region AdaptivePerformanceLoader API Implementation
  52. /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Initialize"/></summary>
  53. /// <returns>True if successful, false otherwise</returns>
  54. public override bool Initialize()
  55. {
  56. IAdaptivePerformanceSettings settings = GetSettings();
  57. if (settings != null)
  58. {
  59. // TODO: Pass settings off to plugin prior to subsystem init.
  60. }
  61. CreateSubsystem<AdaptivePerformanceSubsystemDescriptor, StandaloneSubsystem>(s_StandaloneSubsystemDescriptors, "Standalone Subsystem");
  62. return false;
  63. }
  64. /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Start"/></summary>
  65. /// <returns>True if successful, false otherwise</returns>
  66. public override bool Start()
  67. {
  68. StartSubsystem<StandaloneSubsystem>();
  69. return true;
  70. }
  71. /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Stop"/></summary>
  72. /// <returns>True if successful, false otherwise</returns>
  73. public override bool Stop()
  74. {
  75. StopSubsystem<StandaloneSubsystem>();
  76. return true;
  77. }
  78. /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Deinitialize"/></summary>
  79. /// <returns>True if successful, false otherwise</returns>
  80. public override bool Deinitialize()
  81. {
  82. DestroySubsystem<StandaloneSubsystem>();
  83. return true;
  84. }
  85. #if UNITY_EDITOR
  86. public override void WasAssignedToBuildTarget(BuildTargetGroup buildTargetGroup)
  87. {
  88. WasAssigned = true;
  89. }
  90. public override void WasUnassignedFromBuildTarget(BuildTargetGroup buildTargetGroup)
  91. {
  92. WasUnassigned = true;
  93. }
  94. #endif
  95. #endregion
  96. }
  97. }