This document explains how to communicate between Unity and Android Native.
Requirement:
Android Studio Bumblebee (2021.1.1) or later
Nx_UnityLibrary - Follow this guide to import our UnityLibrary
COMMUNICATIONS:
Android (Java) -> Unity (C#): In Android, start the UnityPlayerActivity from your Activity with an Intent and add data to this intent using putExtra: Intent intent = new Intent(this, UnityPlayerActivity.class); intent.putExtra("gameName", "{value}"); startActivity(intent);
Unity (C#) -> Android (Java): In Android, create a method in UnityPlayerActivity to receive data from Unity. This method can be directly called from Unity: public void onGameFinish(int score) { //will be called on game over } public void onGameQuit() { //will be called on user button press }
Comments