0
안녕하세요 저는 트위터와 페이스 북에서 내 게임을 공유하고 싶습니다.이 스크립트는 트위터에 대한 세부 정보를 공유 할 수있게 해주지 만, 페이스 북에 공유 할 수는 없지만 페이스 북에 텍스트를 보여줍니다. 트위터와는 않습니다 WHATSAPP, 그리고 내가 그것을 게임의 스크린 샷을 소요하고 게시를 추가 있도록 스크립트에 추가하는 방법을 잘 모릅니다 ShareScript입니다 여기에페이스 북, 트위터, whatsapp 등 안드로이드 공유 안드로이드
죄송합니다 나쁜 영어
에 대한나를 도와 그리고하십시오. 도움을
감사합니다 :)
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;
}
}