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.
Tic Tac Toe is a complete game that demonstrates how to use the plugin to implement turn-based multiplayer.
Quiz Racer is a complete game that demonstrates how to use the plugin to implement real-time multiplayer.
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 5.0 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 .unitypackage
- 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 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
There are several achievements for CubicPilot:
Make sure Saved Games is enabled.
- 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: "Play 2 rounds" Description: "Played 2 rounds" Incremental: Yes Steps needed: 2
- Name: "Play 10 rounds" Description: "Played 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.
This is a real-time multi-player game. Create the achievements:
Make sure real-time multiplayer is enabled.
- Name: "Play" Description: "Play Quiz Racer"
- Name: "Score" Description: "Score at least 1 point"
- Name: "Win" Description: "Win a match"
- Name: "Lose" Description: "Lose a match"
- Name: "Don't play" Description: "Don't play a match"
Use QuizRacer.GPGSIds
for the constants class when setting up the game.
This is a sample demonstrating each function.
Make sure Save Games, Real-time and Turn-based multiplayer are enabled.
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 turn-based game.
Events: 1. Name: "Play"
Use TicTacToe.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.