Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/khanhuitse05/unity-mobile-dialog-popup-native
Mobile Dialog Unity (Info, Confirm, Neutral, Date time Picker, Toast, Progress)
https://github.com/khanhuitse05/unity-mobile-dialog-popup-native
Last synced: 3 months ago
JSON representation
Mobile Dialog Unity (Info, Confirm, Neutral, Date time Picker, Toast, Progress)
- Host: GitHub
- URL: https://github.com/khanhuitse05/unity-mobile-dialog-popup-native
- Owner: khanhuitse05
- License: mit
- Created: 2018-05-10T11:22:38.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2022-06-30T06:47:45.000Z (over 2 years ago)
- Last Synced: 2024-07-28T22:54:11.102Z (4 months ago)
- Language: C#
- Size: 678 KB
- Stars: 111
- Watchers: 10
- Forks: 32
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Create Mobile Native Popup Using Unity
## Platform
- iOS
- Android
## Feature
- Ok, Yes/No, Neutral popup (Single, two, three action)- DatePicker, TimePicker
## Easy access from Unity
Welcome to Native Popups for iOS and Android! This plugin provides easy access from Unity to the native functionality of iOS and Android for displaying popups
```csharp
public void OnDialogInfo()
{
NativeDialog.OpenDialog("Info popup", "Welcome To Native Popup", "Ok",
()=> {
Debug.Log("OK Button pressed");
});
}
public void OnDatePicker()
{
NativeDialog.OpenDatePicker(1992,5,10,
(DateTime _date) =>
{
Debug.Log(_date.ToString());
},
(DateTime _date) =>
{
Debug.Log(_date.ToString());
});
}
```
## Open source
I have provide all `java` and `objective c` source. you can know how it work, optimization, or add any features### Android studio
- Unity call to static function
```csharp
AndroidJavaClass javaUnityClass = new AndroidJavaClass("com.pingak9.nativepopup.Bridge");
javaUnityClass.CallStatic("ShowDialogInfo", title, message, ok);
```
- Java show popup
```objectivec
void ShowDialogInfo(String title, String message, String ok) {AlertDialog alertDialog = new AlertDialog.Builder(this).create(); //Read Update
alertDialog.setTitle(title);
alertDialog.setMessage(message);alertDialog.setButton(ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
UnityPlayer.UnitySendMessage("MobileDialogInfo", "OnOkCallBack", "0");
}
});alertDialog.show();
}
```
- Build library jar and file jar to folder Plugins/Android
### Objective C
- Unity call to C
```csharp
[DllImport("__Internal")]
private static extern void _TAG_ShowDialogInfo(string title, string message, string ok);
```
- Objective C show popup
```objectivec
+(void)ShowDialogInfo: (NSString *) title message: (NSString*) msg okTitle:(NSString*) b1 {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:b1 style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[IOSNativePopUpsManager unregisterAllertView];
UnitySendMessage("MobileDialogInfo", "OnOkCallBack", [DataConvertor NSIntToChar:0]);
}];
[alertController addAction:okAction];
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:alertController animated:YES completion:nil];
_currentAllert = alertController;
}
```
- Copy file Objective C to folder Plugins/iOSHappy coding!