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

SamsungAndroidProviderLoader.cs 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.AdaptivePerformance;
  4. #if UNITY_EDITOR
  5. using UnityEditor;
  6. using UnityEditor.AdaptivePerformance.Editor;
  7. #endif
  8. using System.Runtime.InteropServices;
  9. using UnityEngine.AdaptivePerformance.Provider;
  10. namespace UnityEngine.AdaptivePerformance.Samsung.Android
  11. {
  12. /// <summary>
  13. /// SamsungAndroidProviderLoader implements the loader for Adaptive Performance on Samsung devices running Android.
  14. /// </summary>
  15. #if UNITY_EDITOR
  16. [AdaptivePerformanceSupportedBuildTargetAttribute(BuildTargetGroup.Android)]
  17. #endif
  18. public class SamsungAndroidProviderLoader : AdaptivePerformanceLoaderHelper
  19. {
  20. static List<AdaptivePerformanceSubsystemDescriptor> s_SamsungGameSDKSubsystemDescriptors =
  21. new List<AdaptivePerformanceSubsystemDescriptor>();
  22. /// <summary>
  23. /// Returns if the provider loader was initialized successfully.
  24. /// </summary>
  25. public override bool Initialized
  26. {
  27. get
  28. {
  29. #if UNITY_ANDROID
  30. return samsungGameSDKSubsystem != null;
  31. #else
  32. return false;
  33. #endif
  34. }
  35. }
  36. /// <summary>
  37. /// Returns if the provider loader is currently running.
  38. /// </summary>
  39. public override bool Running
  40. {
  41. get
  42. {
  43. #if UNITY_ANDROID
  44. return samsungGameSDKSubsystem != null && samsungGameSDKSubsystem.running;
  45. #else
  46. return false;
  47. #endif
  48. }
  49. }
  50. #if UNITY_ANDROID
  51. /// <summary>Returns the currently active Samsung Android Subsystem instance, if an instance exists.</summary>
  52. public SamsungGameSDKAdaptivePerformanceSubsystem samsungGameSDKSubsystem
  53. {
  54. get { return GetLoadedSubsystem<SamsungGameSDKAdaptivePerformanceSubsystem>(); }
  55. }
  56. #endif
  57. /// <summary>
  58. /// Implementation of <see cref="AdaptivePerformanceLoader.GetDefaultSubsystem"/>.
  59. /// </summary>
  60. /// <returns>Returns the Samsung Android Subsystem, which is the loaded default subsystem. Because only one subsystem can be present at a time, Adaptive Performance always initializes the first subsystem and uses it as a default. You can change subsystem order in the Adaptive Performance Provider Settings.</returns>
  61. public override ISubsystem GetDefaultSubsystem()
  62. {
  63. #if UNITY_ANDROID
  64. return samsungGameSDKSubsystem;
  65. #else
  66. return null;
  67. #endif
  68. }
  69. /// <summary>
  70. /// Implementation of <see cref="AdaptivePerformanceLoader.GetSettings"/>.
  71. /// </summary>
  72. /// <returns>Returns the Samsung Android settings.</returns>
  73. public override IAdaptivePerformanceSettings GetSettings()
  74. {
  75. return SamsungAndroidProviderSettings.GetSettings();
  76. }
  77. /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Initialize"/>.</summary>
  78. /// <returns>True if successfully initialized the Samsung Android subsystem, false otherwise.</returns>
  79. public override bool Initialize()
  80. {
  81. #if UNITY_ANDROID
  82. CreateSubsystem<AdaptivePerformanceSubsystemDescriptor, SamsungGameSDKAdaptivePerformanceSubsystem>(s_SamsungGameSDKSubsystemDescriptors, "SamsungGameSDK");
  83. if (samsungGameSDKSubsystem == null)
  84. {
  85. Debug.LogError("Unable to start the Samsung Android subsystem.");
  86. }
  87. return samsungGameSDKSubsystem != null;
  88. #else
  89. return false;
  90. #endif
  91. }
  92. /// <summary>Implementation of <see cref="AdaptivePerformanceLoader.Start"/>.</summary>
  93. /// <returns>True if successfully started the Samsung Android subsystem, false otherwise.</returns>
  94. public override bool Start()
  95. {
  96. #if UNITY_ANDROID
  97. StartSubsystem<SamsungGameSDKAdaptivePerformanceSubsystem>();
  98. return true;
  99. #else
  100. return false;
  101. #endif
  102. }
  103. /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Stop"/>.</summary>
  104. /// <returns>True if successfully stopped the Samsung Android subsystem, false otherwise.</returns>
  105. public override bool Stop()
  106. {
  107. #if UNITY_ANDROID
  108. StopSubsystem<SamsungGameSDKAdaptivePerformanceSubsystem>();
  109. return true;
  110. #else
  111. return false;
  112. #endif
  113. }
  114. /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Deinitialize"/>.</summary>
  115. /// <returns>True if successfully deinitialized the Samsung Android subsystem, false otherwise.</returns>
  116. public override bool Deinitialize()
  117. {
  118. #if UNITY_ANDROID
  119. DestroySubsystem<SamsungGameSDKAdaptivePerformanceSubsystem>();
  120. return base.Deinitialize();
  121. #else
  122. return false;
  123. #endif
  124. }
  125. }
  126. }