-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "CandyCoded.AlertConfirmDialog", | ||
"references": [ | ||
"CandyCoded.AlertConfirmDialog.Android", | ||
"CandyCoded.AlertConfirmDialog.iOS" | ||
], | ||
"includePlatforms": [ | ||
"Android", | ||
"Editor", | ||
"iOS" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using UnityEngine; | ||
|
||
namespace CandyCoded.AlertConfirmDialog.Android | ||
{ | ||
|
||
public static class AlertConfirmDialog | ||
{ | ||
|
||
private static AndroidJavaObject _androidPlugin; | ||
|
||
private static AndroidJavaObject androidPlugin | ||
{ | ||
get | ||
{ | ||
if (_androidPlugin != null) | ||
{ | ||
return _androidPlugin; | ||
} | ||
|
||
var javaUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | ||
|
||
var currentActivity = javaUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); | ||
|
||
_androidPlugin = | ||
new AndroidJavaObject("com.candycoded.alertconfirmdialog.AndroidPlugin", currentActivity); | ||
|
||
return _androidPlugin; | ||
} | ||
} | ||
|
||
public static void Alert(string title, string message, string okButtonLabel) | ||
{ | ||
androidPlugin.Call("Alert", title, message, okButtonLabel); | ||
} | ||
|
||
public static void Confirm(string title, string message, string okButtonLabel, | ||
string cancelButtonLabel) | ||
{ | ||
androidPlugin.Call("Confirm", title, message, okButtonLabel, cancelButtonLabel); | ||
} | ||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
package com.candycoded.alertconfirmdialog; | ||
|
||
import android.content.Context; | ||
import android.app.AlertDialog; | ||
import android.os.Bundle; | ||
|
||
import com.unity3d.player.UnityPlayer; | ||
|
||
public class AndroidPlugin { | ||
|
||
private Context context; | ||
|
||
public AndroidPlugin(Context context) { | ||
this.context = context; | ||
} | ||
|
||
public void Alert(String title, String message, String okButtonLabel) { | ||
|
||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context); | ||
|
||
alertDialog.setTitle(title); | ||
alertDialog.setMessage(message); | ||
alertDialog.setPositiveButton(okButtonLabel, (dialog, which) -> { | ||
|
||
dialog.dismiss(); | ||
|
||
UnityPlayer.UnitySendMessage("AlertConfirmDialog", "Callback", "OK"); | ||
|
||
}); | ||
alertDialog.create(); | ||
alertDialog.show(); | ||
|
||
} | ||
|
||
public void Confirm(String title, String message, String okButtonLabel, String cancelButtonLabel) { | ||
|
||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context); | ||
|
||
alertDialog.setTitle(title); | ||
alertDialog.setMessage(message); | ||
alertDialog.setPositiveButton(okButtonLabel, (dialog, which) -> { | ||
|
||
dialog.dismiss(); | ||
|
||
UnityPlayer.UnitySendMessage("AlertConfirmDialog", "Callback", "OK"); | ||
|
||
}); | ||
alertDialog.setNegativeButton(cancelButtonLabel, (dialog, which) -> { | ||
|
||
dialog.dismiss(); | ||
|
||
UnityPlayer.UnitySendMessage("AlertConfirmDialog", "Callback", "CANCEL"); | ||
|
||
}); | ||
alertDialog.create(); | ||
alertDialog.show(); | ||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "CandyCoded.AlertConfirmDialog.Android", | ||
"references": [], | ||
"includePlatforms": [ | ||
"Android", | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using System.Runtime.InteropServices; | ||
|
||
namespace CandyCoded.AlertConfirmDialog.iOS | ||
{ | ||
|
||
public static class AlertConfirmDialog | ||
{ | ||
|
||
[DllImport("__Internal")] | ||
public static extern void Alert(string title, string message, string okButtonLabel); | ||
|
||
[DllImport("__Internal")] | ||
public static extern void Confirm(string title, string message, string okButtonLabel, | ||
string cancelButtonLabel); | ||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.