playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.46k stars 967 forks source link

Just can't make Social.localUser.Image to load profile image #1056

Open fzdravko opened 8 years ago

fzdravko commented 8 years ago

I just can't make Social.localUser.Image to load profile image. I tried with StartCoroutine:

    private IEnumerator KeepCheckingAvatar()
    {
        float secondsOfTrying = 10;
        float secondsPerAttempt = 0.2f;
        while (secondsOfTrying > 0)
        {
            if (Social.localUser.image != null)
            {
                // Do something with freshly loaded image
                break;
            }

            secondsOfTrying -= secondsPerAttempt;
            yield return new WaitForSeconds(secondsPerAttempt);
        }
    }

but the result is always null.

syedammarzia commented 8 years ago

Please fix this. I cannot show user avatars in my game. Problem persists on both platforms (IOS & Android).

claywilkinson commented 8 years ago

Have you tried to run the Minimal sample? I ran it and it displayed the avatar of the local player just fine.

fzdravko commented 8 years ago

I think there is a bug. You must first call Social.localUser.userName (and - or - Social.localUser.id) and then with coroutine above load the image. If you only try to load image, it will return null.

vehumet commented 8 years ago

@fzdravko OH MY HOLY GOD! You saved me from the chasm. Thank you very much. My problem was exactly same as the sample code above, and fzdravko's workaround resolved it.

mbonatsos commented 7 years ago

@fzdravko It worked, thanks man.

alo-xvi commented 6 years ago

Can you someone confirm if this code is right?

if (success) { instance.pg_email = ((PlayGamesLocalUser)Social.localUser).Email; instance.pg_userName = ((PlayGamesLocalUser)Social.localUser).userName; Debug.LogWarning ("Google > avatarUrl: " + ((PlayGamesLocalUser)Social.localUser).AvatarURL); instance.pg_avatar = ((PlayGamesLocalUser)Social.localUser).image; } *pg_avatar is a Texture2D object but it always return null or a blank texture. Please Help.