private IEnumerator PostScreenshot() { yield return(new WaitForEndOfFrame()); // Create a texture the size of the screen, RGB24 format int width = Screen.width; int height = Screen.height; Texture2D 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(); Meida.Share("Some text to share", tex); Destroy(tex); }
void OnGUI() { float StartY = 20; float StartX = 10; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Twitter", style); StartY += 40; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Post")) { Twitter.Post("Twitter posting test"); } StartX += 170; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Post Screenshot")) { StartCoroutine(PostTwitterScreenshot()); } StartY += 80; StartX = 10; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Facebook", style); StartY += 40; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Post")) { SA.IOSNative.Social.Facebook.Post("Facebook posting test"); } StartX += 170; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Post Screenshot")) { StartCoroutine(PostFBScreenshot()); } StartX += 170; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Post Image")) { SA.IOSNative.Social.Facebook.Post("Hello world", "https://www.assetstore.unity3d.com/en/#!/publisher/2256", textureForPost); } StartY += 80; StartX = 10; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Native Sharing", style); StartY += 40; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Text")) { Meida.Share("Some text to share"); } StartX += 170; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Screenshot")) { StartCoroutine(PostScreenshot()); } StartX += 170; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Send Mail")) { Mail.Send("Mail Subject", "Mail Body <strong> text html </strong> ", new string[] { "*****@*****.**", "*****@*****.**" }, new Texture2D[] { textureForPost, textureForPost } ); } StartX += 170; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Send Txt Message")) { TextMessage.Send("Hello Google", "+18773555787", ( TextMessageComposeResult result) => { Debug.Log("Message send result: " + result); }); } StartY += 80; StartX = 10; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Instagram", style); StartY += 40; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Post image from camera")) { IOSCamera.OnImagePicked += OnPostImageInstagram; IOSCamera.Instance.PickImage(ISN_ImageSource.Camera); } StartX += 170; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Post Screenshot")) { StartCoroutine(PostScreenshotInstagram()); } StartY += 80; StartX = 10; GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "WhatsApp", style); StartY += 40; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Share Text")) { Whatsapp.Post("Some text"); } StartX += 170; if (GUI.Button(new Rect(StartX, StartY, 150, 50), "Share Image")) { Whatsapp.Post(textureForPost); } }