選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

66 行
2.1 KiB

  1. // Copyright (C) 2017 Google, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #if UNITY_ANDROID
  15. using UnityEngine;
  16. using GoogleMobileAds.Common;
  17. namespace GoogleMobileAds.Android
  18. {
  19. public class MobileAdsClient : IMobileAdsClient
  20. {
  21. private static MobileAdsClient instance = new MobileAdsClient();
  22. private MobileAdsClient(){}
  23. public static MobileAdsClient Instance
  24. {
  25. get
  26. {
  27. return instance;
  28. }
  29. }
  30. public void Initialize(string appId)
  31. {
  32. AndroidJavaClass playerClass = new AndroidJavaClass(Utils.UnityActivityClassName);
  33. AndroidJavaObject activity =
  34. playerClass.GetStatic<AndroidJavaObject>("currentActivity");
  35. AndroidJavaClass mobileAdsClass = new AndroidJavaClass(Utils.MobileAdsClassName);
  36. mobileAdsClass.CallStatic("initialize", activity, appId);
  37. }
  38. public void SetApplicationVolume(float volume)
  39. {
  40. AndroidJavaClass mobileAdsClass = new AndroidJavaClass(Utils.MobileAdsClassName);
  41. mobileAdsClass.CallStatic("setAppVolume", volume);
  42. }
  43. public void SetApplicationMuted(bool muted)
  44. {
  45. AndroidJavaClass mobileAdsClass = new AndroidJavaClass(Utils.MobileAdsClassName);
  46. mobileAdsClass.CallStatic("setAppMuted", muted);
  47. }
  48. public void SetiOSAppPauseOnBackground(bool pause)
  49. {
  50. // Do nothing on Android. Default behavior is to pause when app is backgrounded.
  51. }
  52. }
  53. }
  54. #endif