Нема описа
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.

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