C#, Java, and Cpp Communication in Unity

This post covers four things: How C# calls Java functions in Unity. How Java calls C++ through JNI. How C++ under JNI calls Java. How Java calls Unity’s C#. CSharp Call Java Use Unity’s AndroidJavaObject, and pass the Java class object into the constructor. The format is the package name followed by the class name. For example, in Java: package com.example.jni; public class ExampleJavaClass { // Function with no return value void TestFuncVoid(int a) { /* ... */ } // Function with a return value int TestFuncInt(int a) { /* ... */ } } In CSharp, write it like this: ...

2024-09-12 · 6 min · 1165 words · BlueHour