Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
neogeek committed Feb 24, 2021
0 parents commit 54164f3
Show file tree
Hide file tree
Showing 26 changed files with 629 additions and 0 deletions.
20 changes: 20 additions & 0 deletions CandyCoded.AlertConfirmDialog.asmdef
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
}
7 changes: 7 additions & 0 deletions CandyCoded.AlertConfirmDialog.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Plugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Plugins/Android.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions Plugins/Android/AlertConfirmDialog.cs
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);
}

}

}
3 changes: 3 additions & 0 deletions Plugins/Android/AlertConfirmDialog.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions Plugins/Android/AndroidPlugin.java
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();

}

}
81 changes: 81 additions & 0 deletions Plugins/Android/AndroidPlugin.java.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions Plugins/Android/CandyCoded.AlertConfirmDialog.Android.asmdef
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.

Binary file added Plugins/Android/androidplugin-release.aar
Binary file not shown.
32 changes: 32 additions & 0 deletions Plugins/Android/androidplugin-release.aar.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Plugins/iOS.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Plugins/iOS/AlertConfirmDialog.cs
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);

}

}
11 changes: 11 additions & 0 deletions Plugins/iOS/AlertConfirmDialog.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 54164f3

Please sign in to comment.