PlayGamesClientFactory.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // <copyright file="PlayGamesClientFactory.cs" company="Google Inc.">
  2. // Copyright (C) 2014 Google Inc.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. // </copyright>
  16. #if (UNITY_ANDROID || (UNITY_IPHONE && !NO_GPGS))
  17. namespace GooglePlayGames
  18. {
  19. using UnityEngine;
  20. using GooglePlayGames.BasicApi;
  21. using GooglePlayGames.OurUtils;
  22. internal class PlayGamesClientFactory
  23. {
  24. internal static IPlayGamesClient GetPlatformPlayGamesClient(
  25. PlayGamesClientConfiguration config)
  26. {
  27. if (Application.isEditor)
  28. {
  29. GooglePlayGames.OurUtils.Logger.d("Creating IPlayGamesClient in editor, using DummyClient.");
  30. return new GooglePlayGames.BasicApi.DummyClient();
  31. }
  32. #if UNITY_ANDROID
  33. GooglePlayGames.OurUtils.Logger.d("Creating Android IPlayGamesClient Client");
  34. return new GooglePlayGames.Native.NativeClient(config,
  35. new GooglePlayGames.Android.AndroidClient());
  36. #elif (UNITY_IPHONE && !NO_GPGS)
  37. GooglePlayGames.OurUtils.Logger.d("Creating IOS IPlayGamesClient");
  38. return new GooglePlayGames.Native.NativeClient(config,
  39. new GooglePlayGames.IOS.IOSClient());
  40. #else
  41. GooglePlayGames.OurUtils.Logger.d("Cannot create IPlayGamesClient for unknown platform, returning DummyClient");
  42. return new GooglePlayGames.BasicApi.DummyClient();
  43. #endif
  44. }
  45. }
  46. }
  47. #endif