• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by PARTHA-2014 · Aug 19, 2016 at 06:09 AM · google play gamesturn-basednotifications

How to Track Game Notification from GooglePlayGames to Unity UI ??

I am Working on a Project to implement Google Turn Base Multiplayer in my Game and its working well . i am receiving the notification in my GooglePlay Game Service . But i want to receive it in my Unity GUI ...... is there any library i have to Export (I have Already Exported GooglePlay Game Plugin ) Please Help My Code is Given Below

using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using GooglePlayGames; using GooglePlayGames.BasicApi.Multiplayer; using GooglePlayGames.BasicApi; using UnityEngine.SceneManagement;

using UnityEngine.SocialPlatforms;

// And where is this instanced? MultiplayerController itself? public class MultiplayerController :MonoBehaviour {

 const int Maxopponent = 1;
 const int Minopponent = 1;
 //const int varient = 0;
 private const uint varient = 0xffffffff;
 public string IsActiveId;
 string invitationId=null;
 public static bool CanPlay = false;
 public string ParticipentID = null;
 public string Participent1ID = null;
 //Invitation mIncomingInvitation = null;
 private static MultiplayerController _instance = null;
 //public List <string> ParticipantIDs;
 public List<PlayPlatformController> mListPlayPlatform;
 public TurnBasedMatch GameMatched1; 
 public bool Success1;
 public PlayPlatformController mPlatform;
 public static int IncomingStatus = 0;
 public GameObject MenuUI;
 public GameObject TurnIn;
 public GameObject TurnOut;
 public Text testcase123;
 //Receive Invitation to be place for Callback further ...../
  Invitation wInvitation = null;
  TurnBasedMatch wTurnBased = null;
 public void Awake(){
     
 }
 public void Start(){
     PlayGamesPlatform.Instance.TurnBased.RegisterMatchDelegate (OnMatchReceive);
     PlayGamesPlatform.Instance.RegisterInvitationDelegate (OnInvitationReceive);
     DontDestroyOnLoad(this.gameObject);
     if (mPlatform != null) {
         mPlatform.Start ();
     }
 }

 public void Update(){
     if (mPlatform != null) {
         mPlatform.Update ();
     }
 /*    if (IncomingStatus == 0) {
     MenuUI.SetActive (true);
     }*/
     if (wInvitation != null) {
         ShowIncomingInvitationUI ();
     }

     if (wTurnBased != null) {
         ShowIncomingMatchUI ();    
     }
 }

 public void OnLevelWasLoaded(int level){
     if (level == 4) {
         GameEngine.Instance.SpawnRandomMarbles();
     }
     if (level == 3) {                           // for testing purpose 
         
         if (mPlatform != null) {
             mPlatform.OnLevelWasLoaded (level);
         }
     }
     if (level == 5) {
         if (mPlatform != null) {
             mPlatform.OnLevelWasLoaded (level);
         }
     }
 }
 public void MatchActive(){
     PlayGamesPlatform.Instance.TurnBased.CreateWithInvitationScreen (Minopponent, Maxopponent, varient, OnMatchStarted);
 }
 private void OnMatchStarted(bool success,TurnBasedMatch GameMatched){
 if (success) {
         mPlatform = new PlayPlatformController();
         mPlatform.LaunchGame (GameMatched);
     }
     else {
         Debug.Log ("Error");
     }
 }
 public bool IsAuthenticated() {
     return PlayGamesPlatform.Instance.localUser.authenticated;
 }
 public static MultiplayerController Instance {
     get {
         if (_instance == null) {
             _instance = new MultiplayerController();

         }
         return _instance;
     }
 }
 public void InvitationHandler(Invitation mInvitation,bool InvitationReceive){
     OnInvitationReceive (mInvitation, InvitationReceive);
 }
 public void OnInvitationReceive(Invitation mInvition ,bool OnReceive){                           ///Invitation Receive /// Notification not required 
     if (OnReceive) {
         PlayGamesPlatform.Instance.TurnBased.AcceptInvitation (mInvition.InvitationId, OnMatchStarted);
     }
     else {
         wInvitation = mInvition;

     }
 }
 public void OnMatchHandle(TurnBasedMatch mMatch,bool MatchReceive){                         
     OnMatchReceive (mMatch, MatchReceive);
 }
 public void OnMatchReceive(TurnBasedMatch mMatched, bool OnReceive){                         ///Match Invitation Notification Here Match Begins for player 2 ////                       
     if (OnReceive) {
         GameEngine.Base = new GameObject ("(Singleton)Base").AddComponent<Base> ();
         GameEngine.GameLogic = new GameObject ("(Singleton)GameLogic").AddComponent<GameLogic> ();
         GameEngine.Base.Load ();
         GameEngine.InMatchDel = true;                                                   ///Decide the turn of the Match either receive 
         OnMatchStarted (OnReceive, mMatched);
     }
     else {
         wTurnBased = mMatched;

     }
 }


/ public void SetUpObj(){ GameEngine.Base = new GameObject ("(Singleton)Base").AddComponent (); GameEngine.GameLogic = new GameObject ("(Singleton)GameLogic").AddComponent (); GameEngine.Base.Load (); GameEngine.InMatchDel = true; foreach (MatchData.BlockDesc mBLock in MatchData.mListBlockDesc) { GameEngine.mGameLog.MarbleNumber = mBLock.NumberOfMarbles; GameEngine.mGameLog.BackgroundIndex = mBLock.Background; GameEngine.mGameLog.GameType = mBLock.Gametype; } }/

 public void ShowIncomingInvitationUI(){
     MenuUI.SetActive (false);
     testcase123.text = "New Invitation receive";

 }
 public void ShowIncomingMatchUI(){
     MenuUI.SetActive (false);
     TurnBasedMatch newTurnBased = wTurnBased;
     switch (newTurnBased.TurnStatus) {
     case TurnBasedMatch.MatchTurnStatus.MyTurn:
         TurnIn.SetActive (true);
         break;
     default:
         break;
     }
 }

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

66 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to disable automatch in play-games-plugin-for-unity 0 Answers

TurnbasedGame ios build , not giving match delegate on other player turn complete. 0 Answers

how to deserialize game state from data provide by turn based multiplayer in google play services 0 Answers

Tile-based Enemy AI issue 0 Answers

Unity Photon Pun Turn Based Memory Game 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges