Copyright (c) 2014 Google Inc. All rights reserved.
These are sample games that use the Google Play Games plugin for Unity.
Minimal is a simple sample that has an "Authenticate" button and nothing else. It is meant to show the minimal amount of code necessary to set up an integration with Google Play Games.
Cubic Pilot is a complete game that demonstrates how to use the plugin to implement sign in, achievements, leaderboards and cloud save. It also supports gamepad controllers.
SmokeTest is a "kitchen sink" sample - with buttons for each API call.
Nearby Droids is a game demonstrating the nearby connection API. This sample requires android play services sdk 23 or higher. The nearby connections API is only available on Android. The UI in this game uses the 'new' Unity UI system, so Unity 2017.4 or higher is recommended. For more details and how to build and configure the sample, see Nearby Connections documentation.
Note: This text assumes you have already read and are familiar with the contents of the Getting Started Guide (which is in the README.md file that exists in the root of this Github repository). Make sure to read that file first!
To build a sample, you must first configure a game project game in the Google Play Developer Console. Follow the instructions on creating a client ID for Android and/or iOS (depending on what platforms you intend to run the game). More information about this can be found in the Getting Started Guide.
All the samples follow the same basic steps, see the section for the the specific sample for what resources need to be configured in the play console.
- Create a new Unity Project
- Import the Google Play Games plugin
- Import the <sampleName>.unitypackage (Assets > Import Package)
- In the Play Games developer web app, create the linked application remembering to use the same configuration information when configuring your game in Unity.
- Create the resource configuration needed for the sample in the play console.
- Then at the bottom of the Achievement (or Leaderboards, or Events) list, click "Get Resources", and copy the resource definitions to the clipboard.
- Back in the Unity editor, open the Google Play Games setup dialog 4.1 Enter the constants class name for the sample (listed below for each sample) 4.2 Paste the resource definitions from the Play Console into the text box.
- Click Setup
- Build and run!
Minimal lives up to its name and needs the minimum configuration to test.
- Create 1 Achievment named "Welcome"
- Use the constants class name:
Minimal.GPGSIds
Make sure Saved Games is enabled.
There are several achievements for CubicPilot:
- Name: "Not a Disaster..."
Description: "Get 1 point without dying." - Name: "Point Blank!"
Description: "Kill an enemy at point blank range." - Name: "Full Combo"
Description: "Complete the maximum combo bonus chain." - Name: "Clear All Levels"
Description: "Clear all the levels." - Name: "Perfect Accuracy"
Description: "Clear a level with 100% accuracy." - Name: "Sargent"
Description: "Advancement based on levels completed." - Name: "Captain"
Description: "Advancement based on levels completed." - Name: "Admiral"
Description: "Advancement based on levels completed."
These are incremental achievements that have counts to be met to unlock the achievement.
- Name: "1 Dozen Stars"
Description: "Earn 12 stars"
Incremental: Yes
Steps needed: 12 - Name: "Two Dozen Stars"
Description: "Earn 24 stars"
Incremental: Yes
Steps needed: 24 - Name: "3 Dozen Stars"
Description: "Earn 36 stars"
Incremental: Yes
Steps needed: 36 - Name: "Five Minute Master"
Description: "Play for a total of 5 minutes."
Incremental: Yes
Steps needed: 300 - Name: "30 Minutes of Excitement"
Description: "Play for a total of 30 minutes."
Incremental: Yes
Steps needed: 1800 - Name: "Procrastinate Much?"
Description: "Play for a total of 1 hour."
Incremental: Yes
Steps needed: 3600 - Name: "Played 2 rounds"
Description: "Play 2 rounds"
Incremental: Yes
Steps needed: 2 - Name: "Played 10 rounds"
Description: "Play 10 rounds"
Incremental: Yes
Steps needed: 10 - Name: "Played 25 rounds"
Description: "Play 25 rounds"
Incremental: Yes
Steps needed: 25
Create 1 leaderboard:
- Name: Cubic Pilot Hall of Fame"
Use CubicPilot.GPGSIds
as the name of the constants class when setting up the
game. Also, open the
File > Build Settings > Player Settings > Resolution & Presentation
and disable Portrait
and Portrait Upside Down
rotations by unchecking them.
Note: If the game loads with just a background and no menu, then Unity didn't properly detect the game's scenes. These are located in CubicPilot/Scenes and should be dragged into the Android Build Settings (
File > Build Settings > Android
).
This is a sample demonstrating each function.
Events:
- Name: "SmokingEvent"
Achievements:
- Name: "AchievementToReveal"
Description: "A hidden achievement to be revealed later"
Initial State: "Hidden" - Name: "AchievementToUnlock"
Description: "A normal achievement" - Name: "AchievementToIncrement"
Description: "Incremental achievement to unlock - 25 times"
Incremental: yes
Steps needed: 25 - Name: "Achievement hidden incremental"
Description: "Initially hidden, incremental achievement"
Incremental: yes
Steps needed: 25
Initial State: Hidden - Name: "Lucky5"
Description: "You need 5 achievements to publish"
Leaderboards:
- Name: "Leaders in SmokeTesting"
Use SmokeTest.GPGSIds
for the constants class when setting up the game.
This is a sample for Events and Quests. The Quest definition configuration is left as an exercise for you.
Events:
- Name: "Red"
- Name: "Green"
- Name: "Blue"
- Name: "Yellow"
Use TrivialQuest.GPGSIds
for the constants class when setting up the game.
The Cubic Pilot sample uses the Jura font by Daniel Johnson, available from the Google Web Fonts project.