GPGSUpgrader.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // <copyright file="GPGSUpgrader.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
  17. namespace GooglePlayGames.Editor
  18. {
  19. using System.IO;
  20. using UnityEditor;
  21. using UnityEngine;
  22. /// <summary>
  23. /// GPGS upgrader handles performing and upgrade tasks.
  24. /// </summary>
  25. [InitializeOnLoad]
  26. public class GPGSUpgrader
  27. {
  28. /// <summary>
  29. /// Initializes static members of the <see cref="GooglePlayGames.GPGSUpgrader"/> class.
  30. /// </summary>
  31. static GPGSUpgrader()
  32. {
  33. if (EditorApplication.isPlayingOrWillChangePlaymode)
  34. return;
  35. Debug.Log("GPGSUpgrader start");
  36. GPGSProjectSettings.Instance.Set(GPGSUtil.LASTUPGRADEKEY, PluginVersion.VersionKey);
  37. GPGSProjectSettings.Instance.Set(GPGSUtil.PLUGINVERSIONKEY,
  38. PluginVersion.VersionString);
  39. GPGSProjectSettings.Instance.Save();
  40. bool isChanged = false;
  41. // Check that there is a AndroidManifest.xml file
  42. if (!GPGSUtil.AndroidManifestExists())
  43. {
  44. isChanged = true;
  45. GPGSUtil.GenerateAndroidManifest();
  46. }
  47. if (isChanged)
  48. {
  49. AssetDatabase.Refresh();
  50. }
  51. Debug.Log("GPGSUpgrader done");
  52. }
  53. }
  54. }
  55. #endif