void ScreenshotSaved()

    {
                #if UNITY_IOS || UNITY_IPAD
        GeneralSharingiOSBridge.ShareTextWithImage(ScreenshotHandler.savedImagePath, message);
                #endif
    }
    private IEnumerator ShareAndroid()
    {
        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();
        byte[] screenshot = tex.EncodeToJPG();


        string destination = Path.Combine(Application.persistentDataPath, System.DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".jpg");

        Debug.Log(destination);
        File.WriteAllBytes(destination, screenshot);

        string details  = "This is crazy game. That's great!";
        string gameLink = "https://play.google.com/store/apps/details?id=com.silver.ninjaspin";
        string subject  = "Ninja Spin Game";

                #if UNITY_ANDROID
        if (!Application.isEditor)
        {
            AndroidJavaClass  intentClass  = new AndroidJavaClass("android.content.Intent");
            AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
            intentObject.Call <AndroidJavaObject>("setAction", intentClass.GetStatic <string>("ACTION_SEND"));
            intentObject.Call <AndroidJavaObject>("setType", "image/jpeg");
            AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
            intentObject.Call <AndroidJavaObject>("putExtra", intentClass.GetStatic <string>("EXTRA_TEXT"), details + "\n" + gameLink);
            intentObject.Call <AndroidJavaObject>("putExtra", intentClass.GetStatic <string>("EXTRA_SUBJECT"), subject);

            AndroidJavaObject fileObject = new AndroidJavaObject("java.io.File", destination);            // Set Image Path Here
            AndroidJavaObject uriObject  = uriClass.CallStatic <AndroidJavaObject>("fromFile", fileObject);
            bool fileExist = fileObject.Call <bool>("exists");
            Debug.Log("File exist : " + fileExist);
            if (fileExist)
            {
                intentObject.Call <AndroidJavaObject>("putExtra", intentClass.GetStatic <string>("EXTRA_STREAM"), uriObject);
            }

            AndroidJavaClass  unity           = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = unity.GetStatic <AndroidJavaObject>("currentActivity");
            currentActivity.Call("startActivity", intentObject);
        }
                #elif UNITY_IOS
        string applink = "https://itunes.apple.com/us/app/";
        string path    = Application.persistentDataPath + "/MyImage.png";
        File.WriteAllBytes(path, screenshot);
        string path_ = "MyImage.png";
        GeneralSharingiOSBridge.ShareTextWithImage(path, "This is crazy game. That's great!" + applink);
                #endif


        Destroy(tex);
    }
Exemple #3
0
 void ScreenshotSaved()
 {
             #if UNITY_IPHONE || UNITY_IPAD
     homeBtn.SetActive(true);
     shareBtn.SetActive(true);
     GeneralSharingiOSBridge.ShareTextWithImage(ScreenshotHandler.savedImagePath, GameConstants.SHARE_TEXT_IOS);
             #endif
 }
Exemple #4
0
    void ScreenshotSaved()
    {
#if UNITY_IPHONE || UNITY_IPAD
        byte[] dataToSave = screenCapture.EncodeToPNG();

        string destination = Path.Combine(Application.persistentDataPath, System.DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".png");

        File.WriteAllBytes(destination, dataToSave);

        GeneralSharingiOSBridge.ShareTextWithImage(destination, "");
#endif
    }
Exemple #5
0
    public void shareImageWithText(string title, string text, Texture2D _textureShareImage)
    {
                #if UNITY_EDITOR
                #elif (UNITY_IOS || UNITY_ANDROID)
        // Save your image on designate path
        byte[] bytes = _textureShareImage.EncodeToPNG();
        string path  = Application.persistentDataPath + "/ShareImage.png";
        File.WriteAllBytes(path, bytes);
                #endif

                #if UNITY_EDITOR
                #elif UNITY_IOS
        GeneralSharingiOSBridge.ShareTextWithImage(path, text);
                #elif UNITY_ANDROID
        ShareAndroidImageWithText(path, title, text, _textureShareImage);
                #endif
    }
Exemple #6
0
 // Share Image
 private void ShareImageFromPath(string _destination)
 {
     GeneralSharingiOSBridge.ShareTextWithImage(_destination, message);
 }
Exemple #7
0
 void ScreenshotSaved()
 {
             #if UNITY_IPHONE || UNITY_IPAD
     GeneralSharingiOSBridge.ShareTextWithImage(ScreenshotHandler.savedImagePath, "Hello !!! \nThis is post from TheAppGuruz");
             #endif
 }
Exemple #8
0
 void ScreenshotSaved()
 {
             #if UNITY_IPHONE || UNITY_IPAD
     GeneralSharingiOSBridge.ShareTextWithImage(ScreenshotHandler.savedImagePath, "Kerb Ball");
             #endif
 }
Exemple #9
0
    public static IEnumerator Share(GameObject homeBtn, GameObject shareBtn)
    {
        string dateAndTime = System.DateTime.Now.ToString();

        dateAndTime = dateAndTime.Replace("/", "-");

        string screenshotName = "ScreenShot" + "_" + dateAndTime + ".png";
        string screenshotPath = Path.Combine(Application.persistentDataPath, screenshotName);

        Debug.Log("Arslan:: imagePath = " + screenshotPath);
        //      string filename = "ScreenN123.png";
        Application.CaptureScreenshot(screenshotName);

        while (!System.IO.File.Exists(screenshotPath))
        {
            Debug.Log("Arslan:: waiting ");
            yield return(null);
        }

        homeBtn.SetActive(true);
        shareBtn.SetActive(true);

        AdHandler.GetInstance().showAdmobBanner();
        #if UNITY_ANDROID
        //instantiate the class Intent
        AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");

        //instantiate the object Intent
        AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");

        //call setAction setting ACTION_SEND as parameter
        intentObject.Call <AndroidJavaObject>("setAction", intentClass.GetStatic <string>("ACTION_SEND"));

        //instantiate the class Uri
        AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");

        //instantiate the object Uri with the parse of the url's file
        AndroidJavaObject uriObject = uriClass.CallStatic <AndroidJavaObject>("parse", "file://" + screenshotPath);

        //call putExtra with the uri object of the file
        intentObject.Call <AndroidJavaObject>("putExtra", intentClass.GetStatic <string>("EXTRA_STREAM"), uriObject);
        //call putExtra with the uri object of the file
        intentObject.Call <AndroidJavaObject>("putExtra", intentClass.GetStatic <string>("EXTRA_SUBJECT"), GameConstants.SHARE_SUBJECT);
        //call putExtra with the uri object of the file
        intentObject.Call <AndroidJavaObject>("putExtra", intentClass.GetStatic <string>("EXTRA_TITLE"), GameConstants.SHARE_TITLE);
        //call putExtra with the uri object of the file
        intentObject.Call <AndroidJavaObject>("putExtra", intentClass.GetStatic <string>("EXTRA_TEXT"), GameConstants.SHARE_TEXT);

        //set the type of file
        intentObject.Call <AndroidJavaObject>("setType", "image/jpeg");

        //instantiate the class UnityPlayer
        AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");

        //instantiate the object currentActivity
        AndroidJavaObject currentActivity = unity.GetStatic <AndroidJavaObject>("currentActivity");

        // option one WITHOUT chooser:
        //currentActivity.Call("startActivity", intentObject);

        // option two WITH chooser:
        AndroidJavaObject jChooser = intentClass.CallStatic <AndroidJavaObject>("createChooser", intentObject, GameConstants.SHARE_SUBJECT);
        currentActivity.Call("startActivity", jChooser);
        #endif

        #if UNITY_IOS
        GeneralSharingiOSBridge.ShareTextWithImage(screenshotPath, GameConstants.SHARE_TEXT_IOS);
        #endif
    }
Exemple #10
0
 void ScreenshotSaved()
 {
             #if UNITY_IPHONE || UNITY_IPAD
     GeneralSharingiOSBridge.ShareTextWithImage(ScreenshotHandler.savedImagePath, "Hello !!! \n This image is from Gettinfat");
             #endif
 }