I have made my own C# classes in Unity. How can I access them from the Android Activity that starts the UnityPlayer
?
Example: I have a C# class called testClass
in Unity:
class testClass {
public static string myString = "test string";
}
From the Android activity in Java, I want to access a member of that class:
string str = testClass.myString;
Is this possible? If so, how? Is there another way to do this? In the end, I basically want to communicate between my Android activity and the UnityPlayer object.
Edit: I found a solution.
I looked at building Android plugins for Unity but this wasn't satisfactory to me.
I ended up building a socket client-server interface in Unity with C# and another one in Java for the Android app: Unity listens on port X and broadcasts on port Y. The Android activity listens on port Y and broadcasts on port X. This is necessary as both interfaces are running on the same host.
So that's how I solved my problem, but I'm open for any suggestions if anyone knows a better way of communicating between the Unityplayer and your app.