반응형
공유버튼을 만들어 다음을 추가해주시면 됩니다!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Sharing : MonoBehaviour
{
private const string subject = "원하는 제목";
private const string body = "이곳에 url 넣기";
public void Share()
{
#if UNITY_ANDROID && !UNITY_EDITOR
using (AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"))
using (AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent")) {
intentObject.Call<AndroidJavaObject>("setAction", intentObject.GetStatic<string>("ACTION_SEND"));
intentObject.Call<AndroidJavaObject>("setType", "text/plain");
intentObject.Call<AndroidJavaObject>("putExtra", intentObject.GetStatic<string>("EXTRA_SUBJECT"), subject);
intentObject.Call<AndroidJavaObject>("putExtra", intentObject.GetStatic<string>("EXTRA_TEXT"), body);
using (AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
using (AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity"))
using (AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, "Share Via"))
currentActivity.Call("startActivity", jChooser);
}
#endif
}
}
댓글