diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..f06dfad6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.gradle +build \ No newline at end of file diff --git a/Assets/Public/GooglePlayGames/com.google.play.games/Editor/GPGSUtil.cs b/Assets/Public/GooglePlayGames/com.google.play.games/Editor/GPGSUtil.cs index 4eadb15a..00b25ed8 100644 --- a/Assets/Public/GooglePlayGames/com.google.play.games/Editor/GPGSUtil.cs +++ b/Assets/Public/GooglePlayGames/com.google.play.games/Editor/GPGSUtil.cs @@ -22,6 +22,7 @@ namespace GooglePlayGames.Editor using System.Collections.Generic; using System.IO; using System.Xml; + using System.Linq; using UnityEditor; using UnityEngine; @@ -112,6 +113,44 @@ public static class GPGSUtil private const string RootFolderName = "com.google.play.games"; + static string localResolvedPath = "Packages"; + + public static void InitResolverPath(Action onFinished) + { + var listRequest = UnityEditor.PackageManager.Client.List(true,true); + + EditorApplication.update += Progress; + + void Progress() + { + if(listRequest.Status == UnityEditor.PackageManager.StatusCode.InProgress) + return; + + EditorApplication.update -= Progress; + + if(listRequest.Status == UnityEditor.PackageManager.StatusCode.Failure) + { + Alert(listRequest.Error.errorCode.ToString(),listRequest.Error.message); + onFinished?.Invoke(false); + return; + } + + var packageInfo = listRequest.Result.FirstOrDefault((info) => info.packageId.StartsWith(RootFolderName + "@")); + if(packageInfo == null) + { + Alert(RootFolderName,"Not installed"); + onFinished?.Invoke(false); + return; + } + + if(packageInfo.source == UnityEditor.PackageManager.PackageSource.Local) + localResolvedPath = Path.GetDirectoryName(packageInfo.resolvedPath); + + Debug.Log(localResolvedPath); + onFinished?.Invoke(true); + } + } + /// /// The root path of the Google Play Games plugin /// @@ -119,18 +158,21 @@ public static string RootPath { get { - if (string.IsNullOrEmpty(mRootPath)) + if (string.IsNullOrEmpty(mRootPath) || !Directory.Exists(mRootPath)) { + string[] dirs = new[] { #if UNITY_2018_4_OR_NEWER - // Search for root path in plugin locations for both Asset packages and UPM packages - string[] dirs = Directory.GetDirectories("Packages", RootFolderName, SearchOption.AllDirectories); - string[] dir1 = Directory.GetDirectories("Assets", RootFolderName, SearchOption.AllDirectories); - int dirsLength = dirs.Length; - Array.Resize(ref dirs, dirsLength + dir1.Length); - Array.Copy(dir1, 0, dirs, dirsLength, dir1.Length); -#else - string[] dirs = Directory.GetDirectories("Assets", RootFolderName, SearchOption.AllDirectories); + // search for remote UPM installation + Path.Join("Library","PackageCache"), + localResolvedPath, + "Packages", #endif + "Assets" + }.Distinct().SelectMany((path) => { + return Directory.GetDirectories(path, RootFolderName + "*", SearchOption.AllDirectories); + }).Distinct().ToArray(); + + switch (dirs.Length) { case 0: @@ -144,8 +186,7 @@ public static string RootPath default: for (int i = 0; i < dirs.Length; i++) { - if (File.Exists(SlashesToPlatformSeparator(Path.Combine(dirs[i], GameInfoRelativePath))) - ) + if (File.Exists(SlashesToPlatformSeparator(Path.Combine(dirs[i], GameInfoRelativePath)))) { mRootPath = SlashesToPlatformSeparator(dirs[i]); break; @@ -251,8 +292,7 @@ public static string ReadFile(string filePath) /// Name of the template in the editor directory. public static string ReadEditorTemplate(string name) { - return ReadFile( - Path.Combine(RootPath, string.Format("Editor{0}{1}.txt", Path.DirectorySeparatorChar, name))); + return ReadFile(Path.Combine(RootPath,"Editor",string.Format("{0}.txt", name))); } /// @@ -662,9 +702,7 @@ public static void UpdateGameInfo() /// public static void CheckAndFixDependencies() { - string depPath = - SlashesToPlatformSeparator(Path.Combine(GPGSUtil.RootPath, - "Editor/GooglePlayGamesPluginDependencies.xml")); + string depPath = SlashesToPlatformSeparator(Path.Combine("Assets","Editor","GooglePlayGamesPluginDependencies.xml")); XmlDocument doc = new XmlDocument(); doc.Load(depPath); @@ -694,8 +732,12 @@ public static void CheckAndFixDependencies() /// public static void CheckAndFixVersionedAssestsPaths() { - string[] foundPaths = - Directory.GetFiles(RootPath, "GooglePlayGamesPlugin_v*.txt", SearchOption.AllDirectories); + string[] rootPaths = new string[] { "Assets",RootPath }; + string[] foundPaths = rootPaths.Select((rootPath) => { + return Directory.GetFiles(Path.Combine(rootPath,"Editor"), "GooglePlayGamesPlugin_v*.txt", SearchOption.AllDirectories); + }).FirstOrDefault((txtFiles) => { + return txtFiles.Length > 0 && File.Exists(txtFiles[0]); + }); if (foundPaths.Length == 1) { @@ -710,8 +752,7 @@ public static void CheckAndFixVersionedAssestsPaths() int pos = assetPath.IndexOf(RootFolderName); if (pos != -1) { - assetPath = Path.Combine(RootPath, assetPath.Substring(pos + RootFolderName.Length + 1)) - .Replace("\\", "/"); + assetPath = Path.Combine(RootPath, assetPath.Substring(pos + RootFolderName.Length + 1)).Replace("\\", "/"); } writer.WriteLine(assetPath); diff --git a/Assets/Public/GooglePlayGames/com.google.play.games/Proguard.meta b/Assets/Public/GooglePlayGames/com.google.play.games/Proguard.meta new file mode 100644 index 00000000..7676e0f2 --- /dev/null +++ b/Assets/Public/GooglePlayGames/com.google.play.games/Proguard.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 712f3e21fa801ed47b96558004b29ebe +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Public/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPlugin.txt.meta b/Assets/Public/GooglePlayGames/com.google.play.games/Proguard/games.txt.meta similarity index 63% rename from Assets/Public/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPlugin.txt.meta rename to Assets/Public/GooglePlayGames/com.google.play.games/Proguard/games.txt.meta index 5932b27a..61b67fc7 100644 --- a/Assets/Public/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPlugin.txt.meta +++ b/Assets/Public/GooglePlayGames/com.google.play.games/Proguard/games.txt.meta @@ -1,10 +1,7 @@ fileFormatVersion: 2 -guid: 693a823b8f0ad41fe8231a1b1c8a50da +guid: 9219049b9f9e2b343a059c23d0672b2a TextScriptImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: -labels: -- gvh -- gvh_manifest diff --git a/Assets/Public/GooglePlayGames/com.google.play.games/Runtime.meta b/Assets/Public/GooglePlayGames/com.google.play.games/Runtime.meta new file mode 100644 index 00000000..1b4e5aa4 --- /dev/null +++ b/Assets/Public/GooglePlayGames/com.google.play.games/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fd0ac925755a93f468f9512314445211 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts.meta b/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts.meta new file mode 100644 index 00000000..05a73186 --- /dev/null +++ b/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 59e19e4181908444696b31ddc5d39242 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/BasicApi/Player.cs.meta b/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/BasicApi/Player.cs.meta new file mode 100644 index 00000000..90fb936e --- /dev/null +++ b/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/BasicApi/Player.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 878ac0587c5686b47bcfff564ae5bb27 \ No newline at end of file diff --git a/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/BasicApi/PlayerProfile.cs.meta b/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/BasicApi/PlayerProfile.cs.meta new file mode 100644 index 00000000..7762f341 --- /dev/null +++ b/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/BasicApi/PlayerProfile.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 8b3a4a6424388914289809c499a7f304 \ No newline at end of file diff --git a/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/GameInfo.cs b/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/GameInfo.cs index d6a65d68..2ce15532 100644 --- a/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/GameInfo.cs +++ b/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/GameInfo.cs @@ -13,10 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. // - #if UNITY_ANDROID -namespace GooglePlayGames -{ + +namespace GooglePlayGames { /// /// This file is automatically generated DO NOT EDIT! /// @@ -30,32 +29,33 @@ namespace GooglePlayGames /// by checking whether it still retains its initial value - we prevent the constants from being /// replaced in the aforementioned search/replace by stripping off the leading and trailing "__". /// - public static class GameInfo - { + public static class GameInfo { + private const string UnescapedApplicationId = "APP_ID"; + private const string UnescapedIosClientId = "IOS_CLIENTID"; private const string UnescapedWebClientId = "WEB_CLIENTID"; private const string UnescapedNearbyServiceId = "NEARBY_SERVICE_ID"; public const string ApplicationId = "__APP_ID__"; // Filled in automatically public const string WebClientId = "__WEB_CLIENTID__"; // Filled in automatically public const string NearbyConnectionServiceId = "__NEARBY_SERVICE_ID__"; + public const string IosClientId = "__IOS_CLIENTID__"; // Filled in automatically + public static bool ApplicationIdInitialized() { + return !string.IsNullOrEmpty(ApplicationId) && !ApplicationId.Equals(ToEscapedToken(UnescapedApplicationId)); + } - public static bool ApplicationIdInitialized() - { - return !string.IsNullOrEmpty(ApplicationId) && - !ApplicationId.Equals(ToEscapedToken(UnescapedApplicationId)); + public static bool IosClientIdInitialized() { + return !string.IsNullOrEmpty(IosClientId) && !IosClientId.Equals(ToEscapedToken(UnescapedIosClientId)); } - public static bool WebClientIdInitialized() - { + public static bool WebClientIdInitialized() { return !string.IsNullOrEmpty(WebClientId) && !WebClientId.Equals(ToEscapedToken(UnescapedWebClientId)); } - public static bool NearbyConnectionsInitialized() - { + public static bool NearbyConnectionsInitialized() { return !string.IsNullOrEmpty(NearbyConnectionServiceId) && - !NearbyConnectionServiceId.Equals(ToEscapedToken(UnescapedNearbyServiceId)); + !NearbyConnectionServiceId.Equals(ToEscapedToken(UnescapedNearbyServiceId)); } /// @@ -63,10 +63,9 @@ public static bool NearbyConnectionsInitialized() /// /// The escaped token. /// The Token - private static string ToEscapedToken(string token) - { + private static string ToEscapedToken(string token) { return string.Format("__{0}__", token); } } } -#endif //UNITY_ANDROID \ No newline at end of file +#endif diff --git a/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/PluginVersion.cs b/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/PluginVersion.cs index eaf68209..eb8d263c 100644 --- a/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/PluginVersion.cs +++ b/Assets/Public/GooglePlayGames/com.google.play.games/Runtime/Scripts/PluginVersion.cs @@ -20,7 +20,7 @@ public class PluginVersion { // Current Version. public const int VersionInt = 0x01101; - public const string VersionString = "0.11.01"; + public const string VersionString = "0.11.1"; public const string VersionKey = "01101" ; } } diff --git a/Assets/Public/GooglePlayGames/com.google.play.games/package.json b/Assets/Public/GooglePlayGames/com.google.play.games/package.json index 5b29d7a2..9f5ccf55 100644 --- a/Assets/Public/GooglePlayGames/com.google.play.games/package.json +++ b/Assets/Public/GooglePlayGames/com.google.play.games/package.json @@ -2,7 +2,7 @@ "name": "com.google.play.games", "displayName": "Google Play Games", "description": "The Google Play Games plugin for Unity allows you to access the Google Play Games API through Unity's social interface.", - "version": "0.11.01", + "version": "0.11.1", "unity": "2018.4", "author": { "name": "Google LLC" diff --git a/build.gradle b/build.gradle index ab7c5e55..4c935b3e 100644 --- a/build.gradle +++ b/build.gradle @@ -62,7 +62,7 @@ project.ext { } // Also update in com.google.play.games/package.json - pluginVersion = "0.11.01" + pluginVersion = "0.11.1" // String for specifying the build mode. // If 'eap', will include all files from the 'Protected' folder.