Monday, 8 May 2017

How to integrate google play services using unity

How to integrate google play service in a game successfully?

  1. Download the following for the future to use :-
    1. Download current build google play service plugin from github (https://github.com/playgameservices/play-games-plugin-for-unity)
      
     2. Open build settings from file menu - Switch to android so as to use google play service

     3. Then in the same build settings menu - open player setting it will be opened on the inspector in the right .
  1. Company name : TheRedAndBlack
  2. Product name : ActOfGod
  3. Go to other settings - type this in identification block
    1. Bundle Identifier : com.theredandblack.actofgod
    2. Bundle Version : 1.0.9(according to your current build version)
    3. API Level : 4.1(API level 16)
      d.  Go to publishing settings - create new keystore or if already there use existing keystore
i. Press browse keystore button and select the keystore then type the given keystore password
Ii. select alias from the key panel and create a new key. And select that key
Iii. then type the given password.
Note : to install a new keystore check the youtube video..
Please don’t copy the code provided in the video..

Now create a new c# script and type the following to just initiate the google play service authentication..
And attach it to the main camera.
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
public class Login : MonoBehaviour {

void Awake(){
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate ();

}

// Use this for initialization
void Start () {
Social.localUser.Authenticate ((bool success) => {
});
}   }
Now you need to configure the plugin so as to use it for the present game .

>>Go to the windows - google play games - setup - android setup
>>In the resource definition box delete the previous code and constant class name and
paste the new code which you get in the google developer console by uploading your apk in the
google play services for more details check the video listed below.
After adding the app in the google developer console - now go to game services in the left -
go to achievements in the current game apk - add achievements and finally click on the
get resources - copy the code to the google play games
android configuration menu or also called resource definition in there .
Check this video for more clarity (https://www.youtube.com/watch?v=BhSJK-Kn8Uw&t=1268s)
Note : no need to give client id it creates a file GPGSId’s of that name thats it..
>>then click setup it will create a new GPGSId in the assets folder .. and so it is done..

Now build and check the system.


For deeper understanding check the following link:
https://codelabs.developers.google.com/codelabs/playservices_unity/index.html? index=..%2F..%2Findex#0

1 comment:

  1. After you download the Google play service, we need to import it into the assets so as to get the google option in the windows...

    ReplyDelete