Hello,
I’m using this code to get the profile picture and name from google, but the image becoming grey after signing in.
here’s the code, i’m not a programmer but i do have basic code understanding. can you guys look at it
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using TMPro;
public class PlayGamesManager : MonoBehaviour
{
public Text DetailText;
public Image img;
public GameObject hidesign;
void Start()
{
Signin();
StartCoroutine(localImage());
}
public void Signin()
{
PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
}
internal void ProcessAuthentication(SignInStatus status)
{
if (status == SignInStatus.Success)
{
// Continue with Play Games Services
string name = PlayGamesPlatform.Instance.GetUserDisplayName();
string id = PlayGamesPlatform.Instance.GetUserId();
string ImgUrl = PlayGamesPlatform.Instance.GetUserImageUrl();
DetailText.text = "Welcome \n " + name;
hidesign.SetActive(false);
}
else
{
DetailText.text = "Please Login";
hidesign.SetActive(true);
// Disable your integration with Play Games Services or show a login button
// to ask users to sign-in. Clicking it should call
// PlayGamesPlatform.Instance.ManuallyAuthenticate(ProcessAuthentication).
}
}
IEnumerator localImage()
{
Texture2D tex;
while (Social.localUser.image == null)
{
Debug.Log("Google image not found");
yield return null;
}
Debug.Log("Google image found");
tex = Social.localUser.image;
img.sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0f,0f));
}
}