|
1 | | -# UnityAndroidNativeToolkit |
| 1 | +# UnityAndroidNativeToolkit 🧰 |
| 2 | +*Created by Eric Batlle Clavero* |
2 | 3 |
|
| 4 | +This **Android App** made with **Unity** includes a complete **AndroidToolkit plugin** to allow Unity to **use native Android OS** features such as taking shots with the camera, pop dialogs, pick contacts, etc.. |
| 5 | + |
| 6 | +This repository is divided in 2 parts: |
| 7 | + |
| 8 | +- Unity Project (**C#**) |
| 9 | +- Android Plugin (**Java**) |
| 10 | + |
| 11 | +## Example 🎬 |
| 12 | + |
| 13 | +<p> |
| 14 | + <img src="UnityNativeToolkitImg.png" alt="simple video gif" width="246" height="512"/> |
| 15 | +</p> |
| 16 | + |
| 17 | +*This image shows all UnityAndroidNativeToolkit features UI.* |
| 18 | + |
| 19 | +## Donations are appreciated! 💸 |
| 20 | +*Remember that are many ways to say thank you.* |
| 21 | + |
| 22 | +If this plugin has been helpful remember to star the repository and consider buying me a coffee! 😀 |
| 23 | +<p> |
| 24 | +<a href="https://www.buymeacoffee.com/ebatlleclavero" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-blue.png" alt="Buy Me A Coffee" width="144.6" height="34"></a> |
| 25 | +</p> |
| 26 | + |
| 27 | +If you like my general work and contributions consider [sponsoring me on Github](https://github.com/sponsors/EricBatlle). |
| 28 | + |
| 29 | +But if you just want to donate straightforward, I also have [PayPal.me](https://paypal.me/EricBatlleClavero?locale.x=es_ES). |
| 30 | + |
| 31 | +## How to Use ⚙️ |
| 32 | + |
| 33 | +If you want to test the app, you can download the APK from [here](https://github.com/EricBatlle/UnityAndroidNativeToolkit/releases/download/v1.0/UnityNativeToolkit_1.0.apk). |
| 34 | + |
| 35 | +If you want to open the project and check the code, you need to have **Unity** and **AndroidStudio** installed and updated. |
| 36 | + |
| 37 | +If you want to scratch the code: |
| 38 | + |
| 39 | +- To check **Unity** project, **open the project**, select **NativeToolkit** scene. |
| 40 | +Either inside the unity project or simply dragging the **.cs** classes on your editor, you have to watch on to the classes located on ``UnityAndroidNativeToolkit/Assets/Scripts``. |
| 41 | +- To check **Android Plugin** you can do it opening the solution with **AndroidStudio** and checking the classes located in ``UnityNativeToolkitPlugin_Android\NativeToolkit\src\main\java\com\eric\nativetoolkit``. |
| 42 | + |
| 43 | +App Functionality is simple, just press the feature button you want to test. Some features like Dialogs also have toggles to specify some parameters. |
| 44 | + |
| 45 | + |
| 46 | +On code side, the only thing to keep in mind is to make a Script (like ``NativeToolkit.cs`` in the example) that have a reference to ``NativeToolkitPlugin`` and initialize the plugin doing: ``pluginReferenceVariable = NativeToolkitPlugin.GetPlatformPluginVersion(this.gameObject.name);`` |
| 47 | + |
| 48 | +From here you can call all plugin features simply calling ``pluginReferenceVariable.`` and the feature you want, like ``pluginReferenceVariable.TakeShot()``. |
| 49 | + |
| 50 | +If you don't want to implement all features callbacks, remember to only implement the desired feature interface, like ``INativeCamera``, instead of ``INativeToolkitPlugin``. This last one implements all features interfaces. |
| 51 | + |
| 52 | +## Features 🧰 |
| 53 | + |
| 54 | +- **Camera&Media** |
| 55 | + - Take and Visualize Shots with device camera |
| 56 | + - Save those shots into gallery or private directory |
| 57 | + - Pick and Visualize photos from gallery |
| 58 | +- **Dialogs** |
| 59 | + - Show Alert Dialog |
| 60 | + - Show Date picker Dialog |
| 61 | + - Show Time picker Dialog |
| 62 | + - Show Rate app Dialog |
| 63 | + - Select how many buttons (positive, negative and neutral) appear on dialogs |
| 64 | +- **Toast** |
| 65 | + - Show Toast message |
| 66 | + - Customize duration and position of the toast |
| 67 | +- **Contacts** |
| 68 | + - Pick Contact |
| 69 | +- **Sharing** |
| 70 | + - Share Text |
| 71 | + - Share Image |
| 72 | +- **SpeechRecognizer** |
| 73 | + - Recognize voice commands |
| 74 | + - Recognize voice commands continuously |
| 75 | +- **TextToSpeech (TTS)** |
| 76 | + - Speak text |
| 77 | + - Select language and country for the speaking voice |
| 78 | + |
| 79 | +## Multiple plugins support 🔌 |
| 80 | + |
| 81 | +This plugin has been made following a **fragment-pattern** to avoid errors that can be derived from extending *UnityPlayerActivity*. |
| 82 | + |
| 83 | +This way you can integrate this plugin with your projects even if they already have more plugins. **Truly pluggable**. |
| 84 | + |
| 85 | +If you already have imported on your project the library ``core-1.3.1.aar`` or similar, remember to remove it, or remove the plugin one. |
| 86 | + |
| 87 | +## Upgrading dependencies 📜 |
| 88 | + |
| 89 | +Keep in mind that the actual release ([v1.0](https://github.com/EricBatlle/UnityAndroidNativeToolkit/releases/download/v1.0/UnityNativeToolkit_1.0.apk)) of the plugin works with **AndroidX** dependencies. That means that is targeting **Android 9** (API level 28). |
0 commit comments