Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.playgameservices:play-games-plugin-for-unity:'
}
dependencies {
implementation("com.github.playgameservices:play-games-plugin-for-unity:")
}
<dependency>
<groupId>com.github.playgameservices</groupId>
<artifactId>play-games-plugin-for-unity</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.playgameservices" % "play-games-plugin-for-unity" % ""
:dependencies [[com.github.playgameservices/play-games-plugin-for-unity ""]]
Copyright (c) 2014 Google Inc. All rights reserved.
The Google Play Games plugin for Unity® is an open-source project whose goal is to provide a plugin that allows game developers to integrate with the Google Play Games API from a game written in Unity®. However, this project is not in any way endorsed or supervised by Unity Technologies.
Unity® is a trademark of Unity Technologies.
iOS is a trademark of Apple, Inc.
Please download the package from the Github release page.
The Google Play Games plugin for Unity allows you to access the Google Play Games API through Unity's social interface. The plugin provides support for the following features of the Google Play Games API:<br/>
NOTICE: This version of the plugin no longer supports iOS. Google Play games services for iOS is deprecated, and is not likely to function as expected. Do not use Google Play games services for iOS in new apps. See the deprecation announcement blog post for more details.
Features:
For instructions on using the plugin, please refer to this developer guide.
For a sample application demonstrating how to use Google Play Games see SmokeTest project;
If you have already integrated your project with a previous version of the plugin and wish to upgrade to a new version, please refer to the upgrade instructions.
In order to access Google APIs on a backend web server on behalf of the current player, you need to get an authentication code from the client application and pass this to your web server application. This code can then be exchanged for an access token to make calls to the various APIs. For more details on this flow see: Google Sign-In for Websites.
To get the Server Auth code:
1. Configure the web client Id of the web application linked to your game in the
Play Game Console.
2. Call PlayGamesClientConfiguration.Builder.RequestServerAuthCode(false)
when
creating the configuration.
3. Call PlayGamesPlatform.Instance.GetServerAuthCode()
once the player is authenticated.
4. Pass this code to your server application.
PlayGamesPlatform.Instance.RequestServerSideAccess(
/* forceRefreshToken= */ false,
code -> {
// send code to server
});
It is possible to decrease the size of the Play Games Services Unity Plugin by removing code for the Play Games Services features that your game doesn’t use by using Proguard. Proguard will remove the Play Games Unity plugin code for features that are not used in your game, so your game ships with only the code that is needed and minimizes the size impact of using Play Games Services.
Additionally, it is possible to reduce the size of the entire Unity project using Unity’s Managed Code Stripping, which will compress your entire project. This can be used in conjunction with Proguard.
File > Build Settings > Player Settings
and click Publishing Settings
section. Choose Proguard
for Minify > Release
. Then, enable User Proguard File
. If you want the plugin to be proguarded for debug apks as well, you can choose Proguard
for Minify > Debug
.Assets/Plugins/Android/proguard-user.txt
.When you call PlayGamesPlatform.Activate
, Google Play Games becomes your default social platform implementation, which means that static calls to methods in Social
and Social.Active
will be carried out by the Google Play Games plugin. This is the desired behavior for most games using the plugin.
However, if for some reason you wish to keep the default implementation accessible (for example, to use it to submit achievements and leaderboards to a different social platform), you can use the Google Play Games plugin without overriding the default one. To do this:
PlayGamesPlatform.Activate
Xyz
is the name of a method you wish to call on the Social
class, do not call Social.Xyz
. Instead, call PlayGamesPlatform.Instance.Xyz
Social.Active
when interacting with Google Play Games. Instead, use PlayGamesPlatform.Instance
.That way, you can even submit scores and achievements simultaneously to two or more social platforms:
// Submit achievement to original default social platform
Social.ReportProgress("MyAchievementIdHere", 100.0f, callback);
// Submit achievement to Google Play
PlayGamesPlatform.Instance.ReportProgress("MyGooglePlayAchievementIdHere", 100.0f, callback);
This section lists people who have contributed to this project by writing code, improving documentation or fixing bugs.