IEnumerator Share(bool authorized) { //share logined account ScreenCanvas.SetActive(true); string t = ""; if (authorized) { t = "Lets play with my account!"; GameObject.Find("Share_account_name").GetComponent <Text>().text = "@" + PlayerStats.instance.playerSettings.name; } else { GameObject.Find("Share_account_name").GetComponent <Text>().text = ""; t = "Lets play InstaJong!"; } GameObject.Find("Share_header").GetComponent <Text>().text = t; string path = Application.persistentDataPath + "/share_screen.png"; yield return(new WaitForEndOfFrame()); //Texture2D tex = ScreenCapture.CaptureScreenshotAsTexture(); //DataSave.SaveImage(tex, "share_screen", Application.persistentDataPath); var height = 600; var width = 600; Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false); Rect _r = new Rect(0, 0, width, height); tex.ReadPixels(_r, 0, 0); tex.Apply(); DataSave.SaveImage(tex, "share_screen", Application.persistentDataPath, true); Debug.Log(path + " - screenshot saved"); //yield return new WaitForSeconds(0.05f); ScreenCanvas.SetActive(false); if (authorized) { AnalyticsEventsController.LogEvent("Share", "share_type", "authorized"); new NativeShare().SetTitle("lets play InstaJong!").SetText("Find my account and play! @" + PlayerStats.instance.playerSettings.name + "\n https://play.google.com/apps/testing/com.GeM.InstaJong \n\n\n #InstaJong").AddFile(path).Share(); } else { AnalyticsEventsController.LogEvent("Share", "share_type", "Not_authorized"); new NativeShare().SetTitle("lets play InstaJong!").SetText("Hey, lets go play InstaJong! \n https://play.google.com/apps/testing/com.GeM.InstaJong \n\n\n #InstaJong").AddFile(path).Share(); } if (!PlayerPrefs.HasKey(_shareKey)) { PlayerStats.instance.AddInstaCoins(500); AddICBuyShare.SetActive(false); PlayerPrefs.SetInt(_shareKey, 1); } }