【发布时间】:2015-10-22 14:43:36
【问题描述】:
我正在尝试获取玩家的用户名,然后显示它。
最近发生了重大变化; FBResult 的 IResult 替换。
我能够从 IGraphResult 而不是 FBResult 返回纹理以显示个人资料图片,因此我希望 Text 也可以使用,但没有。
所以我的问题是,我可以从哪里返回文本? 我必须向 IGraphResult 添加任何内容吗?
这是代码,
void DealWithUserName(FBResult result)
{
if(result.Error != null)
{
Debug.Log ("Problems with getting profile picture");
FB.API ("/me?fields=id,first_name", HttpMethod.GET, DealWithUserName);
return;
}
profile = Util.DeserializeJSONProfile(result.Text);
Text UserMsg = UIFBUsername.GetComponent<Text>();
UserMsg.text = "Hello, " + profile["first_name"];
}
编辑: 好的,我做到了。 看来我也可以从 IGraphResult 中获取用户名。 因此,我将 FBResult 更改为 IGraphResult。 我将 result.Text 更改为 result.RawResult。
这里是代码,供需要的人使用。
void DealWithUserName(IGraphResult result)
{
if(result.Error != null)
{
Debug.Log ("Problems with getting profile picture");
FB.API ("/me?fields=id,first_name", HttpMethod.GET, DealWithUserName);
return;
}
profile = Util.DeserializeJSONProfile(result.RawResult);
Text UserMsg = UIFBUsername.GetComponent<Text>();
UserMsg.text = "Hello, " + profile["first_name"];
}
【问题讨论】:
标签: facebook text facebook-unity-sdk