Unity 和 NGUI 有小问题。NGUI 有 UITexture 作为它的主要纹理,例如 Unity 有 GUITexture。
我向 facebook 发送了一个请求,以获取用户的个人资料图片,该图片发回了一个完美的 url,如果我把它放在浏览器中就可以了。
我的问题是使用 Texture2D(Facebook API 将其作为 Texture2D)并将其放在我的 UITexture 上。由于某种原因,它只是不正确地接受它。我不断得到它的空值。我也在使用移动社交以及资产商店的任何帮助,有帮助。
这是我的代码片段。
private void UserDataLoaded(FB_Result result)
{
SPFacebook.OnUserDataRequestCompleteAction -= UserDataLoaded;
if (result.IsSucceeded)
{
Debug.Log("User Data Loaded!");
IsUserInfoLoaded = true;
string FBNametxt = SPFacebook.Instance.userInfo.Name;
UILabel Name = GameObject.Find("FBName").GetComponent<UILabel>();
Name.text = FBNametxt;
Texture2D FBLoadTex = SPFacebook.Instance.userInfo.GetProfileImage(FB_ProfileImageSize.normal);
FBGetProfile.GetComponent<UITexture>().mainTexture = FBLoadTex != null ? FBLoadTex : PlaceHolderImg;
}
else {
Debug.Log("User data load failed, something was wrong");
}
}
如果 fbprofile pic 确实为空,则占位符图像只是已选择的图像。我不断得到......