MNUseExample.cs
3.03 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
////////////////////////////////////////////////////////////////////////////////
//
// @module <module_name>
// @author Osipov Stanislav lacost.st@gmail.com
//
////////////////////////////////////////////////////////////////////////////////
using UnityEngine;
using System.Collections;
public class MNUseExample : MNFeaturePreview {
public string appleId = "";
public string androidAppUrl = "market://details?id=com.google.earth";
void Awake() {
}
void OnGUI() {
UpdateToStartPos();
GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Native Pop Ups", style);
StartY+= YLableStep;
if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Rate PopUp with events")) {
MobileNativeRateUs ratePopUp = new MobileNativeRateUs("Like this game?", "Please rate to support future updates!");
ratePopUp.SetAppleId(appleId);
ratePopUp.SetAndroidAppUrl(androidAppUrl);
ratePopUp.OnComplete += OnRatePopUpClose;
ratePopUp.Start();
}
StartX += XButtonStep;
if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Dialog PopUp")) {
MobileNativeDialog dialog = new MobileNativeDialog("Dialog Titile", "Dialog message");
dialog.OnComplete += OnDialogClose;
Invoke("Dismiss", 2.0f);
}
StartX += XButtonStep;
if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Message PopUp")) {
MobileNativeMessage msg = new MobileNativeMessage("Message Titile", "Message message");
msg.OnComplete += OnMessageClose;
}
StartY += YButtonStep;
StartX = XStartPos;
if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Prealoder")) {
MNP.ShowPreloader("Title", "Message");
Invoke("OnPreloaderTimeOut", 3f);
}
StartX += XButtonStep;
if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Hide Prealoder")) {
MNP.HidePreloader();
}
}
private void Dismiss() {
Debug.Log("DIALOG DISMISS");
MNAndroidNative.dismissDialog();
}
//--------------------------------------
// GET/SET
//--------------------------------------
//--------------------------------------
// EVENTS
//--------------------------------------
private void OnPreloaderTimeOut() {
MNP.HidePreloader();
}
private void OnRatePopUpClose(MNDialogResult result) {
//parsing result
switch(result) {
case MNDialogResult.RATED:
Debug.Log ("Rate Option pickied");
break;
case MNDialogResult.REMIND:
Debug.Log ("Remind Option pickied");
break;
case MNDialogResult.DECLINED:
Debug.Log ("Declined Option pickied");
break;
}
new MobileNativeMessage("Result", result.ToString() + " button pressed");
}
private void OnDialogClose(MNDialogResult result) {
//parsing result
switch(result) {
case MNDialogResult.YES:
Debug.Log ("Yes button pressed");
break;
case MNDialogResult.NO:
Debug.Log ("No button pressed");
break;
}
new MobileNativeMessage("Result", result.ToString() + " button pressed");
}
private void OnMessageClose() {
new MobileNativeMessage("Result", "Message Closed");
}
}