Bez popisu
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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. #if UNITY_ANDROID
  23. /// <summary>Returns the currently active Samsung Android Subsystem instance, if an instance exists.</summary>
  24. public SamsungGameSDKAdaptivePerformanceSubsystem samsungGameSDKSubsystem
  25. {
  26. get { return GetLoadedSubsystem<SamsungGameSDKAdaptivePerformanceSubsystem>(); }
  27. }
  28. #endif
  29. /// <summary>
  30. /// Implementation of <see cref="AdaptivePerformanceLoader.GetDefaultSubsystem"/>.
  31. /// </summary>
  32. /// <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>
  33. public override ISubsystem GetDefaultSubsystem()
  34. {
  35. #if UNITY_ANDROID
  36. return samsungGameSDKSubsystem;
  37. #else
  38. return null;
  39. #endif
  40. }
  41. /// <summary>
  42. /// Implementation of <see cref="AdaptivePerformanceLoader.GetSettings"/>.
  43. /// </summary>
  44. /// <returns>Returns the Samsung Android settings.</returns>
  45. public override IAdaptivePerformanceSettings GetSettings()
  46. {
  47. return SamsungAndroidProviderSettings.GetSettings();
  48. }
  49. /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Initialize"/>.</summary>
  50. /// <returns>True if successfully initialized the Samsung Android subsystem, false otherwise.</returns>
  51. public override bool Initialize()
  52. {
  53. #if UNITY_ANDROID
  54. CreateSubsystem<AdaptivePerformanceSubsystemDescriptor, SamsungGameSDKAdaptivePerformanceSubsystem>(s_SamsungGameSDKSubsystemDescriptors, "SamsungGameSDK");
  55. if (samsungGameSDKSubsystem == null)
  56. {
  57. Debug.LogError("Unable to create the Samsung Android subsystem.");
  58. return false;
  59. }
  60. if (!samsungGameSDKSubsystem.initialized)
  61. {
  62. if (!samsungGameSDKSubsystem.Initialize())
  63. {
  64. Debug.LogError("Unable to initialize the Samsung Android subsystem.");
  65. return false;
  66. }
  67. }
  68. return samsungGameSDKSubsystem != null && samsungGameSDKSubsystem.initialized;
  69. #else
  70. return false;
  71. #endif
  72. }
  73. /// <summary>Implementation of <see cref="AdaptivePerformanceLoader.Start"/>.</summary>
  74. /// <returns>True if successfully started the Samsung Android subsystem, false otherwise.</returns>
  75. public override bool Start()
  76. {
  77. #if UNITY_ANDROID
  78. StartSubsystem<SamsungGameSDKAdaptivePerformanceSubsystem>();
  79. return true;
  80. #else
  81. return false;
  82. #endif
  83. }
  84. /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Stop"/>.</summary>
  85. /// <returns>True if successfully stopped the Samsung Android subsystem, false otherwise.</returns>
  86. public override bool Stop()
  87. {
  88. #if UNITY_ANDROID
  89. StopSubsystem<SamsungGameSDKAdaptivePerformanceSubsystem>();
  90. return true;
  91. #else
  92. return false;
  93. #endif
  94. }
  95. /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Deinitialize"/>.</summary>
  96. /// <returns>True if successfully deinitialized the Samsung Android subsystem, false otherwise.</returns>
  97. public override bool Deinitialize()
  98. {
  99. #if UNITY_ANDROID
  100. DestroySubsystem<SamsungGameSDKAdaptivePerformanceSubsystem>();
  101. return true;
  102. #else
  103. return false;
  104. #endif
  105. }
  106. }
  107. }