一切工作正常在Android上,但我不知道如何使它適用於iOS,請幫助。統一共享腳本Android到iOS
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.IO;
using System;
using System.Collections.Generic;
public class ShareMenu : MonoBehaviour
{
private bool isProcessing = false;
public string AppLinkURL { get; set; }
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";
public void shareImage()
{
if (!isProcessing)
StartCoroutine(ShareScreenshot());
}
private IEnumerator ShareScreenshot()
{
isProcessing = true;
yield return new WaitForEndOfFrame();
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");
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), shareText + gameLink);
intentObject.Call<AndroidJavaObject>("setType", "text/plain");
AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
currentActivity.Call("startActivity", intentObject);
isProcessing = false;
}
}
}
你能以某種方式幫助我改變了IOS 此代碼讓我分享到Facebook,Twitter,WhatsApp的。因爲在Android上它工作得很好。我是編程的新手。
會發生什麼? –
@SP。它只是關閉的應用程序,有時它凍結 –