android - Social.localuser.image is always returning null -


i using unity along google play services plugin unity found on here: https://github.com/playgameservices/play-games-plugin-for-unity

i trying access players avatar included in profile pic ingame. problem when try accessing texture2d social.localuser.image, returns null. upon more research seems code uses kind of avatarurl find image , thing null. used string.isnullorempty(avatarurl) check this. know why avatarurl null, and/or how can fix it. if not that, there alternative way accessing players avatar use profile picture in game.

here code used test this:

playgamesplatform.activate();  //authenticate user social.localuser.authenticate((bool success) => {     if(success) {         debug.log("successfully authenticated");         textures.profilepic = sprite.create(social.localuser.image, new rect(0, 0, social.localuser.image.width, social.localuser.image.height), new vector2(0.5f, 0.5f));         scenemanager.loadscene("main menu");     } else {         debug.log("failed authenticate user");         scenemanager.loadscene("errorcannotsignin");     } }); 

the error happens when setting textures.profilepic (textures class created stores textures, , profilepic static sprite variable in it). says there nullreferenceexception: object reference not set instance of object.

again based on i've seen, think source of error seems avatarurl being null, causes code, pretty sure loads image, not run:

if (!mimageloading && mimage == null && !string.isnullorempty(avatarurl)) {     debug.log("starting load image: " + avatarurl);     mimageloading = true;     playgameshelperobject.runcoroutine(loadimage()); } 

also if it's important, testing on android device.

question answered jeanluc on this question

the implementation social.localuser.image of play games unity plugin returns null.


Comments