Skip to content

Commit

Permalink
fix number + find packages system + move java bridge to native compiled
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaina committed Sep 25, 2024
1 parent cf42dbb commit c5eb7db
Show file tree
Hide file tree
Showing 71 changed files with 145 additions and 2,054 deletions.
5 changes: 0 additions & 5 deletions Assets/Plugins/Android.meta

This file was deleted.

143 changes: 0 additions & 143 deletions Assets/Plugins/Android/GooglePlayGamesManifest.androidlib.meta

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

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:20.1.0"/>
<androidPackage spec="com.google.android.gms:play-services-nearby:19.3.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 @@ -22,6 +22,7 @@ namespace GooglePlayGames.Editor
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Linq;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -107,8 +108,7 @@ public static class GPGSUtil
/// </summary>
/// <remarks>The Games SDK requires additional metadata in the AndroidManifest.xml
/// file. </remarks>
private const string ManifestRelativePath =
"../../Plugins/Android/GooglePlayGamesManifest.androidlib/AndroidManifest.xml";
private const string ManifestRelativePath = "Plugins/Android/GooglePlayGamesManifest.androidlib/AndroidManifest.xml";

private const string RootFolderName = "com.google.play.games";

Expand All @@ -119,18 +119,26 @@ public static string RootPath
{
get
{
if (string.IsNullOrEmpty(mRootPath))
if (string.IsNullOrEmpty(mRootPath) || !Directory.Exists(mRootPath))
{
#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<string>(ref dirs, dirsLength + dir1.Length);
Array.Copy(dir1, 0, dirs, dirsLength, dir1.Length);
#else
string[] dirs = Directory.GetDirectories("Assets", RootFolderName, SearchOption.AllDirectories);
mRootPath = Path.GetFullPath(Path.Combine("Packages",RootFolderName));
if(Directory.Exists(mRootPath))
return mRootPath;
#endif

string[] dirs = new[] {
#if UNITY_2018_4_OR_NEWER
// search for remote UPM installation
Path.Join("Library","PackageCache"),
"Packages",
#endif
"Assets"
}.Distinct().SelectMany((path) => {
return Directory.GetDirectories(path, RootFolderName + "*", SearchOption.AllDirectories);
}).Distinct().ToArray();


switch (dirs.Length)
{
case 0:
Expand All @@ -144,8 +152,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;
Expand Down Expand Up @@ -177,7 +184,7 @@ public static string RootPath
/// </summary>
private static string GameInfoPath
{
get { return SlashesToPlatformSeparator(Path.Combine(RootPath, GameInfoRelativePath)); }
get { return SlashesToPlatformSeparator(Path.Combine("Assets", GameInfoRelativePath)); }
}

/// <summary>
Expand All @@ -187,7 +194,7 @@ private static string GameInfoPath
/// file. </remarks>
private static string ManifestPath
{
get { return SlashesToPlatformSeparator(Path.Combine(RootPath, ManifestRelativePath)); }
get { return SlashesToPlatformSeparator(Path.Combine("Assets", ManifestRelativePath)); }
}

/// <summary>
Expand Down Expand Up @@ -251,8 +258,7 @@ public static string ReadFile(string filePath)
/// <param name="name">Name of the template in the editor directory.</param>
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)));
}

/// <summary>
Expand Down Expand Up @@ -662,9 +668,9 @@ public static void UpdateGameInfo()
/// </summary>
public static void CheckAndFixDependencies()
{
string depPath =
SlashesToPlatformSeparator(Path.Combine(GPGSUtil.RootPath,
"Editor/GooglePlayGamesPluginDependencies.xml"));
string depPath = SlashesToPlatformSeparator(Path.Combine("Assets","Editor","GooglePlayGamesPluginDependencies.xml"));
if(!File.Exists(depPath))
return;

XmlDocument doc = new XmlDocument();
doc.Load(depPath);
Expand Down Expand Up @@ -694,10 +700,18 @@ public static void CheckAndFixDependencies()
/// </summary>
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) => {
string editorPath = Path.Combine(rootPath,"Editor");
if(!Directory.Exists(editorPath))
return Array.Empty<string>();

if (foundPaths.Length == 1)
return Directory.GetFiles(editorPath, "GooglePlayGamesPlugin_v*.txt", SearchOption.AllDirectories);
}).FirstOrDefault((txtFiles) => {
return txtFiles.Length > 0 && File.Exists(txtFiles[0]);
});

if (foundPaths?.Length == 1)
{
string tmpFilePath = Path.GetTempFileName();

Expand All @@ -710,8 +724,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);
Expand Down

This file was deleted.

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
@@ -1,8 +1,10 @@
-keep class com.google.android.gms.games.PlayGames { *; }
-keep class com.google.android.gms.games.leaderboard.** { *; }
-keep class com.google.android.gms.games.snapshot.** { *; }
-keep class com.google.android.gms.games.achievement.** { *; }
-keep class com.google.android.gms.games.event.** { *; }
-keep class com.google.android.gms.games.stats.** { *; }
-keep class com.google.android.gms.games.video.** { *; }
-keep class com.google.android.gms.games.* { *; }
-keep class com.google.android.gms.common.api.ResultCallback { *; }
-keep class com.google.android.gms.signin.** { *; }
Expand All @@ -17,4 +19,5 @@
-keep class com.google.android.gms.common.GooglePlayServicesUtil { *; }
-keep class com.google.android.gms.common.api.** { *; }
-keep class com.google.android.gms.common.data.DataBufferUtils { *; }
-keep class com.google.android.gms.games.quest.** { *; }
-keep class com.google.android.gms.nearby.** { *; }

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

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

Loading

0 comments on commit c5eb7db

Please sign in to comment.