ForceNoGpgsForIOS.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // <copyright file="ForceNoGpgsForIOS.cs" company="Google Inc.">
  2. // Copyright (C) 2018 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. namespace GooglePlayGames.Editor
  17. {
  18. using System.Collections;
  19. using System.Collections.Generic;
  20. using UnityEngine;
  21. #if UNITY_2017
  22. using UnityEditor.Build;
  23. #endif
  24. using UnityEditor;
  25. [InitializeOnLoad]
  26. public class ForceNoGpgsForIOS
  27. #if UNITY_2017
  28. : IActiveBuildTargetChanged
  29. #endif
  30. {
  31. static ForceNoGpgsForIOS ()
  32. {
  33. setNoGPGS ();
  34. }
  35. public void OnActiveBuildTargetChanged (BuildTarget previousTarget, BuildTarget newTarget)
  36. {
  37. if (newTarget == BuildTarget.iOS) {
  38. setNoGPGS ();
  39. }
  40. }
  41. public int callbackOrder { get { return 0; } }
  42. private static void setNoGPGS ()
  43. {
  44. Debug.Log ("Forcing NO_GPGS to be defined for iOS builds.");
  45. string symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup (BuildTargetGroup.iOS);
  46. if (string.IsNullOrEmpty (symbols)) {
  47. symbols = "NO_GPGS";
  48. } else if (!symbols.Contains ("NO_GPGS")) {
  49. symbols += ";NO_GPGS";
  50. }
  51. PlayerSettings.SetScriptingDefineSymbolsForGroup (BuildTargetGroup.iOS, symbols);
  52. }
  53. }
  54. }