Skip to content

Commit 54164f3

Browse files
committed
Initial commit.
0 parents  commit 54164f3

26 files changed

+629
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "CandyCoded.AlertConfirmDialog",
3+
"references": [
4+
"CandyCoded.AlertConfirmDialog.Android",
5+
"CandyCoded.AlertConfirmDialog.iOS"
6+
],
7+
"includePlatforms": [
8+
"Android",
9+
"Editor",
10+
"iOS"
11+
],
12+
"excludePlatforms": [],
13+
"allowUnsafeCode": false,
14+
"overrideReferences": false,
15+
"precompiledReferences": [],
16+
"autoReferenced": true,
17+
"defineConstraints": [],
18+
"versionDefines": [],
19+
"noEngineReferences": false
20+
}

CandyCoded.AlertConfirmDialog.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Plugins.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Plugins/Android.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information.
2+
3+
using UnityEngine;
4+
5+
namespace CandyCoded.AlertConfirmDialog.Android
6+
{
7+
8+
public static class AlertConfirmDialog
9+
{
10+
11+
private static AndroidJavaObject _androidPlugin;
12+
13+
private static AndroidJavaObject androidPlugin
14+
{
15+
get
16+
{
17+
if (_androidPlugin != null)
18+
{
19+
return _androidPlugin;
20+
}
21+
22+
var javaUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
23+
24+
var currentActivity = javaUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
25+
26+
_androidPlugin =
27+
new AndroidJavaObject("com.candycoded.alertconfirmdialog.AndroidPlugin", currentActivity);
28+
29+
return _androidPlugin;
30+
}
31+
}
32+
33+
public static void Alert(string title, string message, string okButtonLabel)
34+
{
35+
androidPlugin.Call("Alert", title, message, okButtonLabel);
36+
}
37+
38+
public static void Confirm(string title, string message, string okButtonLabel,
39+
string cancelButtonLabel)
40+
{
41+
androidPlugin.Call("Confirm", title, message, okButtonLabel, cancelButtonLabel);
42+
}
43+
44+
}
45+
46+
}

Plugins/Android/AlertConfirmDialog.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Plugins/Android/AndroidPlugin.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information.
2+
3+
package com.candycoded.alertconfirmdialog;
4+
5+
import android.content.Context;
6+
import android.app.AlertDialog;
7+
import android.os.Bundle;
8+
9+
import com.unity3d.player.UnityPlayer;
10+
11+
public class AndroidPlugin {
12+
13+
private Context context;
14+
15+
public AndroidPlugin(Context context) {
16+
this.context = context;
17+
}
18+
19+
public void Alert(String title, String message, String okButtonLabel) {
20+
21+
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
22+
23+
alertDialog.setTitle(title);
24+
alertDialog.setMessage(message);
25+
alertDialog.setPositiveButton(okButtonLabel, (dialog, which) -> {
26+
27+
dialog.dismiss();
28+
29+
UnityPlayer.UnitySendMessage("AlertConfirmDialog", "Callback", "OK");
30+
31+
});
32+
alertDialog.create();
33+
alertDialog.show();
34+
35+
}
36+
37+
public void Confirm(String title, String message, String okButtonLabel, String cancelButtonLabel) {
38+
39+
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
40+
41+
alertDialog.setTitle(title);
42+
alertDialog.setMessage(message);
43+
alertDialog.setPositiveButton(okButtonLabel, (dialog, which) -> {
44+
45+
dialog.dismiss();
46+
47+
UnityPlayer.UnitySendMessage("AlertConfirmDialog", "Callback", "OK");
48+
49+
});
50+
alertDialog.setNegativeButton(cancelButtonLabel, (dialog, which) -> {
51+
52+
dialog.dismiss();
53+
54+
UnityPlayer.UnitySendMessage("AlertConfirmDialog", "Callback", "CANCEL");
55+
56+
});
57+
alertDialog.create();
58+
alertDialog.show();
59+
60+
}
61+
62+
}

Plugins/Android/AndroidPlugin.java.meta

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "CandyCoded.AlertConfirmDialog.Android",
3+
"references": [],
4+
"includePlatforms": [
5+
"Android",
6+
"Editor"
7+
],
8+
"excludePlatforms": [],
9+
"allowUnsafeCode": false,
10+
"overrideReferences": false,
11+
"precompiledReferences": [],
12+
"autoReferenced": true,
13+
"defineConstraints": [],
14+
"versionDefines": [],
15+
"noEngineReferences": false
16+
}

Plugins/Android/CandyCoded.AlertConfirmDialog.Android.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)