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.