I have seen:
How to get user's profile picture with Facebook's Unity SDK??
I tried it but I am getting following error
You are trying to load data from a www stream which has not completed the download yet. You need to yield the download or wait until isDone returns true.
Please help.
The problem is clearly stated in the error message.
When using the WWW class, you need to wait for the class to finish downloading the information before accessing it. There are two ways of doing so.
Yielding the WWW and calling the method as a Coroutine
public IEnumerator GetFacebookProfilePicture (string userID) {
WWW profilePic = new WWW ("http://graph.facebook.com/" + userID + "/picture?type=large"); //+ "?access_token=" + FB.AccessToken);
yield return profilePic;
//Do whatever here
}
Call the above as follows
StartCoroutine(GetFacebookProfilePicture (userID));
The other option is to check the isDone property of the WWW class. It's not very different
public IEnumerator GetFacebookProfilePicture (string userID) {
WWW profilePic = new WWW ("http://graph.facebook.com/" + userID + "/picture?type=large"); //+ "?access_token=" + FB.AccessToken);
while(!profilePic.isDone)
yield return new WaitForEndOfFrame();
//Do whatever here
}
Obviously, ensure that you're calling the above as a Coroutine as well.