Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<dependencies>
<androidPackages>
<androidPackage spec="com.google.android.gms:play-services-games-v2:21.0.0"/>
<androidPackage spec="com.google.android.gms:play-services-nearby:18.5.0"/>
</androidPackages>
</dependencies>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ namespace GooglePlayGames.Editor
using UnityEditor;
using UnityEngine;

#if UNITY_2021_2_OR_NEWER
using UnityEditor.Build;
#endif

/// <summary>
/// Google Play Game Services Setup dialog for Android.
/// </summary>
Expand Down Expand Up @@ -57,15 +61,14 @@ public class GPGSAndroidSetupUI : EditorWindow
/// <summary>
/// Menus the item for GPGS android setup.
/// </summary>
[MenuItem("Window/Google Play Games/Setup/Android setup...", false, 1)]
[MenuItem("Google/Play Games/Setup/Android setup...", false, 1)]
public static void MenuItemFileGPGSAndroidSetup()
{
EditorWindow window = EditorWindow.GetWindow(
typeof(GPGSAndroidSetupUI), true, GPGSStrings.AndroidSetup.Title);
var window = EditorWindow.GetWindow<GPGSAndroidSetupUI>(true, GPGSStrings.AndroidSetup.Title);
window.minSize = new Vector2(500, 400);
}

[MenuItem("Window/Google Play Games/Setup/Android setup...", true)]
[MenuItem("Google/Play Games/Setup/Android setup...", true)]
public static bool EnableAndroidMenuItem()
{
#if UNITY_ANDROID
Expand Down Expand Up @@ -111,8 +114,6 @@ public static bool PerformSetup(
// check the bundle id and set it if needed.
CheckBundleId();

GPGSUtil.CheckAndFixDependencies();
GPGSUtil.CheckAndFixVersionedAssestsPaths();
AssetDatabase.Refresh();

Google.VersionHandler.VerboseLoggingEnabled = true;
Expand Down Expand Up @@ -162,26 +163,26 @@ public static bool PerformSetup(string webClientId, string appId, string nearbyS
}
}

// check for valid app id
if (!GPGSUtil.LooksLikeValidAppId(appId) && string.IsNullOrEmpty(nearbySvcId))
{
GPGSUtil.Alert(GPGSStrings.Setup.AppIdError);
return false;
}

if (nearbySvcId != null)
if(string.IsNullOrEmpty(nearbySvcId))
{
#if UNITY_ANDROID
if (!NearbyConnectionUI.PerformSetup(nearbySvcId, true))
// check for valid app id
if (!GPGSUtil.LooksLikeValidAppId(appId))
{
GPGSUtil.Alert(GPGSStrings.Setup.AppIdError);
return false;
}
#endif
}
#if UNITY_ANDROID
else if (!NearbyConnectionUI.PerformSetup(nearbySvcId, true))
{
return false;
}
#endif

GPGSProjectSettings.Instance.Set(GPGSUtil.APPIDKEY, appId);
GPGSProjectSettings.Instance.Set(GPGSUtil.WEBCLIENTIDKEY, webClientId);
GPGSProjectSettings.Instance.Save();
GPGSUtil.PatchAndroidManifest();
GPGSUtil.UpdateGameInfo();

// check that Android SDK is there
Expand All @@ -196,7 +197,7 @@ public static bool PerformSetup(string webClientId, string appId, string nearbyS
}

// Generate AndroidManifest.xml
GPGSUtil.GenerateAndroidManifest();
GPGSUtil.UpdateGameInfo();

// refresh assets, and we're done
AssetDatabase.Refresh();
Expand Down Expand Up @@ -298,9 +299,8 @@ public void OnGUI()
}
catch (Exception e)
{
GPGSUtil.Alert(
GPGSStrings.Error,
"Invalid classname: " + e.Message);
GPGSUtil.Alert(GPGSStrings.Error,"Invalid classname: " + e.Message);
Debug.LogException(e);
}
}

Expand Down Expand Up @@ -355,48 +355,45 @@ public static void CheckBundleId()
string packageName = GPGSProjectSettings.Instance.Get(
GPGSUtil.ANDROIDBUNDLEIDKEY, string.Empty);
string currentId;
#if UNITY_5_6_OR_NEWER
currentId = PlayerSettings.GetApplicationIdentifier(
BuildTargetGroup.Android);
#if UNITY_2021_2_OR_NEWER
currentId = PlayerSettings.GetApplicationIdentifier(NamedBuildTarget.Android);
#elif UNITY_5_6_OR_NEWER
currentId = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android);
#else
currentId = PlayerSettings.bundleIdentifier;
#endif
if (!string.IsNullOrEmpty(packageName))
if (string.IsNullOrEmpty(packageName))
{
if (string.IsNullOrEmpty(currentId) ||
currentId == "com.Company.ProductName")
{
#if UNITY_5_6_OR_NEWER
PlayerSettings.SetApplicationIdentifier(
BuildTargetGroup.Android, packageName);
Debug.Log("NULL package!!");
}
else if (string.IsNullOrEmpty(currentId) || currentId == "com.Company.ProductName")
{
#if UNITY_2021_2_OR_NEWER
PlayerSettings.SetApplicationIdentifier(NamedBuildTarget.Android, packageName);
#elif UNITY_5_6_OR_NEWER
PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, packageName);
#else
PlayerSettings.bundleIdentifier = packageName;
PlayerSettings.bundleIdentifier = packageName;
#endif
}
else if (currentId != packageName)
}
else if (currentId != packageName)
{
if (EditorUtility.DisplayDialog(
"Set Bundle Identifier?",
"The server configuration is using " + packageName +
", but the player settings is set to " + currentId +
".\nSet the Bundle Identifier to " + packageName + "?",
"OK", "Cancel"))
{
if (EditorUtility.DisplayDialog(
"Set Bundle Identifier?",
"The server configuration is using " +
packageName + ", but the player settings is set to " +
currentId + ".\nSet the Bundle Identifier to " +
packageName + "?",
"OK",
"Cancel"))
{
#if UNITY_5_6_OR_NEWER
PlayerSettings.SetApplicationIdentifier(
BuildTargetGroup.Android, packageName);
#if UNITY_2021_2_OR_NEWER
PlayerSettings.SetApplicationIdentifier(NamedBuildTarget.Android, packageName);
#elif UNITY_5_6_OR_NEWER
PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, packageName);
#else
PlayerSettings.bundleIdentifier = packageName;
PlayerSettings.bundleIdentifier = packageName;
#endif
}
}
}
else
{
Debug.Log("NULL package!!");
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,26 @@ namespace GooglePlayGames.Editor

public class GPGSDocsUI
{
[MenuItem("Window/Google Play Games/Documentation/Plugin Getting Started Guide...", false, 100)]
[MenuItem("Google/Play Games/Documentation/Plugin Getting Started Guide...", false, 100)]
public static void MenuItemGettingStartedGuide()
{
Application.OpenURL(GPGSStrings.ExternalLinks.GettingStartedGuideURL);
}

[MenuItem("Window/Google Play Games/Documentation/Google Play Games API...", false, 101)]
[MenuItem("Google/Play Games/Documentation/Google Play Games API...", false, 101)]
public static void MenuItemPlayGamesServicesAPI()
{
Application.OpenURL(GPGSStrings.ExternalLinks.PlayGamesServicesApiURL);
}

[MenuItem("Window/Google Play Games/About/About the Plugin...", false, 300)]
[MenuItem("Google/Play Games/About/About the Plugin...", false, 300)]
public static void MenuItemAbout()
{
string msg = GPGSStrings.AboutText +
PluginVersion.VersionString + " (" +
string.Format("0x{0:X8}", GooglePlayGames.PluginVersion.VersionInt) + ")";
EditorUtility.DisplayDialog(GPGSStrings.AboutTitle, msg,
GPGSStrings.Ok);
string msg = GPGSStrings.AboutText + PluginVersion.VersionString + " (" + string.Format("0x{0:X8}", GooglePlayGames.PluginVersion.VersionInt) + ")";
EditorUtility.DisplayDialog(GPGSStrings.AboutTitle, msg, GPGSStrings.Ok);
}

[MenuItem("Window/Google Play Games/About/License...", false, 301)]
[MenuItem("Google/Play Games/About/License...", false, 301)]
public static void MenuItemLicense()
{
EditorUtility.DisplayDialog(GPGSStrings.LicenseTitle, GPGSStrings.LicenseText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#if UNITY_ANDROID
namespace GooglePlayGames.Editor
{
using System.Collections.Generic;
using System.IO;
using UnityEditor.Callbacks;
using System.Linq;

using UnityEditor;
using UnityEngine;
using UnityEditor.Callbacks;


public static class GPGSPostBuild
public class GPGSPostBuild : AssetPostprocessor
{
[PostProcessBuild(99999)]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
Expand All @@ -37,6 +37,12 @@ public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProj

return;
}

static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload)
{
if(didDomainReload || importedAssets.Concat(deletedAssets).Concat(movedAssets).Any((path) => path.EndsWith("AndroidManifest.xml")))
GPGSUtil.PatchAndroidManifest();
}
}
}
#endif //UNITY_ANDROID
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,13 @@ static GPGSUpgrader()
Debug.Log("GPGSUpgrader start");

GPGSProjectSettings.Instance.Set(GPGSUtil.LASTUPGRADEKEY, PluginVersion.VersionKey);
GPGSProjectSettings.Instance.Set(GPGSUtil.PLUGINVERSIONKEY,
PluginVersion.VersionString);
GPGSProjectSettings.Instance.Set(GPGSUtil.PLUGINVERSIONKEY, PluginVersion.VersionString);
GPGSProjectSettings.Instance.Save();

bool isChanged = false;
// Check that there is a AndroidManifest.xml file
if (!GPGSUtil.AndroidManifestExists())
{
isChanged = true;
GPGSUtil.GenerateAndroidManifest();
}
GPGSUtil.UpdateGameInfo();

AssetDatabase.Refresh();

if (isChanged)
{
AssetDatabase.Refresh();
}
Debug.Log("GPGSUpgrader done");
}
}
Expand Down
Loading