예제 #1
0
    static void Share(string shareText, string imagePath, string url, string subject = "Share")
    {
        #if UNITY_EDITOR
        Debug.Log("To use the share method, build the game for android, IOS or windows phone 8.1 platform.");
        #elif UNITY_ANDROID
        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://" + imagePath);
        intentObject.Call <AndroidJavaObject>("putExtra", intentClass.GetStatic <string>("EXTRA_STREAM"), uriObject);
        intentObject.Call <AndroidJavaObject>("setType", "image/png");

        intentObject.Call <AndroidJavaObject>("putExtra", intentClass.GetStatic <string>("EXTRA_TEXT"), shareText);

        AndroidJavaClass  unity           = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = unity.GetStatic <AndroidJavaObject>("currentActivity");

        AndroidJavaObject jChooser = intentClass.CallStatic <AndroidJavaObject>("createChooser", intentObject, subject);
        currentActivity.Call("startActivity", jChooser);
        #elif UNITY_IOS
        CallSocialShareAdvanced(shareText, subject, url, imagePath);
        #elif UNITY_METRO || UNITY_WP_8_1
        ServicesNativeWP81.Share(" ", shareText);
        #endif
    }
예제 #2
0
 public static void Rate()
 {
     #if UNITY_ANDROID
     Application.OpenURL("market://details?id=" + _applicationAndroidID);
     #elif UNITY_IOS
     Application.OpenURL("itms-apps://itunes.apple.com/app/id" + _applicationIOSID);
     #elif UNITY_METRO || UNITY_WP_8_1
     ServicesNativeWP81.RateGame();
     #else
     Debug.Log("No rate set up for this platform.");
     #endif
 }
예제 #3
0
    public static IEnumerator ShareScreenshotWithText(string text)
    {
                #if UNITY_METRO || UNITY_WP_8_1
        string screenShotPath = ServicesNativeWP81.PathLocalFolderWP81(_screenshotName);
        Application.CaptureScreenshot(screenShotPath);
                #else
        string screenShotPath = Application.persistentDataPath + "/" + _screenshotName;
        Application.CaptureScreenshot(_screenshotName);
                #endif

        yield return(0);

        text += "\n" + GetURLStore();
        Share(text, screenShotPath, "");
    }