2016-07-11 61 views
0

你好,我想在Twitter和Facebook上分享我的遊戲,這個腳本允許我分享詳細信息到Twitter,WhatsApp,但我不能在Facebook上分享它不會在Facebook上顯示文本,但在Twitter和WhatsApp的它,我不知道如何在加入腳本,以便它需要遊戲的截圖,並將其添加後請幫我團結共享Facebook,Twitter,WhatsApp的等Android

對不起,我英文不好

,這裏是ShareScript。

感謝您的幫助:)

using UnityEngine; 
using System.Collections; 
using UnityEngine.UI; 
using System.IO; 

public class ShareMenu : MonoBehaviour 
{ 

    private bool isProcessing = false; 

    private string shareText = "Download This Game"; 
    private string gameLink = "Download the game on play store at " + "\nhttps://play.google.com/store/apps/details?id=com.CrazyDrivers"; 
    private string imageName = "MyPic"; // without the extension, for iinstance, MyPic 
    public void shareImage() 
    { 

     if (!isProcessing) 
      StartCoroutine(ShareScreenshot()); 

    } 

    private IEnumerator ShareScreenshot() 
    { 
     isProcessing = true; 
     yield return new WaitForEndOfFrame(); 

     Texture2D screenTexture = new Texture2D(1080, 1080, TextureFormat.RGB24, true); 
     screenTexture.Apply(); 


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

     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")); 
      AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); 
      AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + destination); 
      intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject); 
      intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), shareText + gameLink); 
      intentObject.Call<AndroidJavaObject>("setType", "image/jpeg"); 
      AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); 
      AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity"); 

      currentActivity.Call("startActivity", intentObject); 

     } 

     isProcessing = false; 

    } 

} 

回答

相關問題