In the process of integrating a Unity application into my native application developed in Android Studio, I now intend to process the data obtained in the Unity application. More specifically, I have developed an augmented reality quiz, and I want to send the "score" variable obtained at the end of the quiz to the Native App in order to process it and subsequently send it to Firebase. My issue lies in establishing communication between the Unity library and the Native App. From the Native App, I can only launch the UnityPlayerActivity.
I tried to develop the following function in NativeApp Kotlin:
object UnityBridge {
private var score: Int = 5
fun setScore(newScore: Int) {
score = newScore
println("UnityBridge: Score set to $score")
}
fun getScore(): Int {
return score
}
}
And the following in Unity C# :
void ScoreSet()
{
AndroidJavaClass unityBridgeClass = new AndroidJavaClass("com.example.profilenlogin.ScoreActivity");
unityBridgeClass.CallStatic("setScore", score);
}
However, I continue to receive a null value, not corresponding to the actual score value.