Social.localUser.Image在Unity3d中返回null

我想在Android和IOS中访问玩家头像,我可以使用Social Class获取用户ID和用户名,但图像总是返回null!

if ( Social.localUser.authenticated && Social.localUser.image != null ) { Material m = new Material(Shader.Find("Unlit/Transparent Colored")); m.mainTexture = Social.localUser.image; AvatarImage.material = m; } 

任何想法。

Unity中的Social API仅适用于iOS。

对于Google Play服务,我真的建议购买prime31 Google Play游戏服务插件 ,价格为75美元。

另外还有来自谷歌的Open Source Play Games Unity插件 ,但是我不能推荐它,因为我无法在没有登录错误的情况下正确集成它。

更新1

Play Games Unity插件的 Social.localUser.image实现返回null。 请参阅PlayGamesUserProfile.cs

我正在使用此Google API暂时从谷歌获取头像。 从谷歌插件,你可以在AndroidClient类中创建一个辅助函数,用于从Android获取图像,这将返回一个URI。

 if (Social.localUser.authenticated && Social.localUser.image != null) { GameObject UserAvatar = GameObject.FindGameObjectWithTag("UserAvatar"); if (UserAvatar != null) UserAvatar.GetComponent().sprite = Sprite.Create(Social.localUser.image, new Rect(0, 0, 50, 50), new Vector2(0, 0)); }