Hello folks, first, I must say that I have post this question 3 times in Unity Community (include answer hub and its forum) but no one can solve it. I use TakeScreenShot() function (it's in the InteractiveConsole example in Facebook SDK for Unity) to take a screenshot and post it to FB. But there are 2 problems appeared:
- First: the screenshot that's captured is a gray blank like this: (sorry, I don't have permission to post an image)
- Second: No one can see my post except me although I set the photo to public.
How can I fix these problems ? Thank you.
Here is the code of TakeScreenShot() function
private IEnumerator TakeScreenshot() {
yield return new WaitForEndOfFrame();
var width = Screen.width;
var height = Screen.height;
var tex = new Texture2D(width, height, TextureFormat.RGB24, false);
// Read screen contents into the texture
tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
tex.Apply();
byte[] screenshot = tex.EncodeToPNG();
var wwwForm = new WWWForm();
wwwForm.AddBinaryData("image", screenshot, "InteractiveConsole.png");
wwwForm.AddField("message", "herp derp. I did a thing! Did I do this right?");
FB.API("me/photos", Facebook.HttpMethod.POST, Callback, wwwForm);
Debug.Log("done");
}