-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameOver.cs
107 lines (75 loc) · 2.9 KB
/
GameOver.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System.Runtime.InteropServices;
using UnityEngine.SceneManagement;
using UnityEngine.SocialPlatforms;
public class gameOver : MonoBehaviour {
public GameObject AddObj;
string subject = "Subject text";
string body = "Actual text (Link)";
#if UNITY_IPHONE
[DllImport("__Internal")]
private static extern void sampleMethod (string iosPath, string message);
[DllImport("__Internal")]
private static extern void sampleTextMethod (string message);
#endif
public void OnAndroidTextSharingClick()
{
StartCoroutine(ShareAndroidText());
}
IEnumerator ShareAndroidText()
{
yield return new WaitForEndOfFrame();
//execute the below lines if being run on a Android device
#if UNITY_ANDROID
//Reference of AndroidJavaClass class for intent
AndroidJavaClass intentClass = new AndroidJavaClass ("android.content.Intent");
//Reference of AndroidJavaObject class for intent
AndroidJavaObject intentObject = new AndroidJavaObject ("android.content.Intent");
//call setAction method of the Intent object created
intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
//set the type of sharing that is happening
intentObject.Call<AndroidJavaObject>("setType", "text/plain");
//add data to be passed to the other activity i.e., the data to be sent
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), subject);
//intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TITLE"), "Text Sharing ");
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), body);
//get the current activity
AndroidJavaClass unity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
//start the activity by sending the intent data
AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, "Share Via");
currentActivity.Call("startActivity", jChooser);
#endif
}
public void OniOSTextSharingClick()
{
#if UNITY_IPHONE || UNITY_IPAD
string shareMessage = "Wow I Just Share Text "; // change this
sampleTextMethod (shareMessage);
#endif
}
// This is the part for Rating
public void RateUs()
{
#if UNITY_ANDROID
Application.OpenURL("market://details?id=1032952831467");
/* I think this ID will be provided by PLAYSTORE, but for time-being attach this script
to the button and check with some random URL */
#elif UNITY_IPHONE
Application.OpenURL("itms-apps://itunes.apple.com/app/idYOUR_ID");
#endif
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void ExitPress(){
Application.Quit ();
}
}