Tuesday, 11 April 2017

Google Play Games Services for Unity Plugin

As promised in last weeks blog Late Panda by Late Panda by Stephen. I (Ellie) shall this week be talking about a couple of issues we had when implementing the Google Play Services into Late Panda (The Game) and what to expect if you’re planning on doing something similar.


Just before I do though, I’d like to remind you all that Late Panda is our third title this year. All Late Panda games so far are available on Android.


LPG Icon 512 v2.pngIcon.png512 Icon.png


As you may know, Late Panda is doing the 1GAM Challenge. Release a game every month for 12 months, simple. We want to try to do something different for each game. Either something unique or just something we’ve never done ourselves before. Qbits is an infinite idle game, Echoes of Hope is the super depressing mental health awareness “interactive experience” and Late Panda is, as far as we know, the first of it’s kind. A hybrid memory-infinite runner with Google Play Service integration for achievements and a worldwide leaderboard.


Late Panda was initially developed in Unity for Android. We then decided it would be good to release the game in different places like our website latepanda.com (Desktop only) and on the new Facebook Gameroom (Coming soon).




This is the first time we’d be implementing the Google Play Services into a game. Knowing how popular the Unity game engine is, I was pretty confident there’d be an easy to integrate plugin available. Surprise, there is, and it’s recommended by Google themselves.




This plugin only supports Android and iOS builds. Our chosen target platforms however are:


[ ] Android
[ ] WebGL
[ ] Gameroom (Facebook)


Because we’re developing these games quickly the decision was made to use the plugin and simply exclude the Google Play Services on the WebGL and Gameroom platforms even though Google Play Services does offer support for:


[ ] Android
[ ] iOS
[ ] Web
[ ] Chrome
[ ] Other


This is just something to be aware of if you’re thinking about using the plugin.


Now, if you import the plugin, then try to build a non-Android or iOS version of your game you’re going to have a bad time. To get around this we’re using a wonderful little feature in Unity called Platform dependent compilation. They’re essentially IF statements but they’re super useful for building cross-platform games as they avoid compiling unnecessary code depending on your current platform. You can read up on them here  unity3d.com/Manual/PlatformDependentCompilation.


using UnityEngine;
using System.Collections;

public class PlatformDefines : MonoBehaviour {
 void Start () {

   #if UNITY_EDITOR
     Debug.Log("Unity Editor");
   #endif
   
   #if UNITY_IOS
     Debug.Log("Iphone");
   #endif

   #if UNITY_STANDALONE_OSX
   Debug.Log("Stand Alone OSX");
   #endif

   #if UNITY_STANDALONE_WIN
     Debug.Log("Stand Alone Windows");
   #endif

 }          
}


That’s just a couple of things to be aware of that I thought I’d mention. The best playable experience for Late Panda is the Android version as it contains the worldwide leaderboard and 9 unlockable achievements. If we come back to this game when we have more time I might look into integrating the Google Play Services into all the platforms or hopefully by that point the plugin will support more than Android and iOS.


Thanks for reading, I hope you found this useful. Remember you can follow us all over the internet.


Ellie xx


“My face is tired from dealing with… everything” - Foster Addison