- Home /
Display player image and name using google
I am working on multiplayer game and I want to attach player name and photograph that it attach with it google account. I have implemented Google Play Games for my game.
So I have doing login with Google but can't know how to use account detail such as name and photograph? I know more information related to this. Please give some suggestion in this.
Answer by praveee · Aug 27, 2014 at 03:30 AM
If you using Google Play Games plugin for Unity plugin it allows you to access the Google Play Games API through Unity's social interface.
void Awake()
{
Social.localUser.Authenticate (ProcessAuthentication);
}
private void ProcessAuthentication (bool success)
{
if (success)
{
UserName = Social.localUser.userName; // UserName
UserID = Social.localUser.id; // UserID
ProfilePic =Social.localUser.image; // ProfilePic
}
else
{
Debug.LogWarning ("Failed to authenticate");
}
}
Thanks @praveee, I will check this and reply you shortly. Also if you have information regarding player data management then please give it also.
I have use google for accessing player data for multiplayer game or move towards facebook integration.
What is your suggestion?
What do you mean by player data management? using google or facebook as social platform will depending on your target audience.
The Social.localUser.image is always going to be null. You have to use the URI for the profile picture with the Image$$anonymous$$anager. Or that's what has been said here. I just can't figure out how to do it haha.
Answer by Adishah11 · Jun 06, 2018 at 08:24 AM
Also assign some texture to "tex" (tex is Texture2D)
void RealTimeMultiplayerListener.OnRoomConnected (bool success) { debug.text = "Connected"; Participant p = PlayGamesPlatform.Instance.RealTime.GetSelf ();
MineId.text = p.ParticipantId;
MineName.text = p.DisplayName;
StartCoroutine (image(p.Player.AvatarURL));
}
IEnumerator image(string url){
using (WWW www = new WWW (url)) {
yield return www;
www.LoadImageIntoTexture (tex);
ImgMine.sprite = Sprite.Create (tex, new Rect (0.0f, 0.0f, tex.width, tex.height), new Vector2 (0f, 0f));
}
}
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Unity photon network - game room 1 Answer
Google Sketchup model problem in Unity 1 Answer
Unity Network Instantiate Issue 0 Answers
Where to get official support for the Google Play OBB Downloader plugin? 1 Answer