Hi I have this code that works on one of my game but on the other game the picture is not being taken but the text is there. when i try to send it on for example watsapp then error occours saying "sending failed try again later" can you tell me what could be causing this?
public void shareScreen ()
{
Texture2D MyImage = new Texture2D (Screen.width, Screen.height, TextureFormat.RGB24, true);
MyImage.ReadPixels (new Rect (0f, 0f, Screen.width, Screen.height), 0, 0);
MyImage.Apply ();
byte[] bytes = MyImage.EncodeToPNG ();
string path = Application.persistentDataPath + "/MyImage.png";
File.WriteAllBytes (path, bytes);
AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
intentObject.Call("setAction", intentClass.GetStatic("ACTION_SEND"));
AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
AndroidJavaObject uriObject = uriClass.CallStatic("parse","file://" + path);
intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_STREAM"), uriObject);
intentObject.Call ("setType", "text/plain");
intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_TITLE"),"Color Shoot");
intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_TEXT"), "" + "My Score " + gc.score);
intentObject.Call("setType", "image/jpeg");
AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic("currentActivity");
currentActivity.Call("startActivity", intentObject);
}
↧