Hello Readers !!
Today we are going to discuss a very interesting topic. Yes, i.e. Facebook Sharing to get more users for our apps or games.
If you don't know about how to create FaceBook app then please read my following Blog:-
http://findnerd.com/account#url=/list/view/Create-Facebook-App-for-Unity3D/24119/
Or If you know about app creation but you don't know about code part then read my following blog first:-
http://findnerd.com/account#url=/list/view/Facebook-Integration-With-Unity3D/24007/
Once you go through the above blogs then here is the code to share screenshot on Facebook:-
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");
FB.API("me/photos", HttpMethod.POST, Callback, wwwForm);
}
void Callback(IGraphResult result1)
{
result = result1.ToString();
}
Try this and share what every you want from your app.
Till then keep coding..
0 Comment(s)