Android Activity access Unity Classes
Posted
by
Anomaly
on Game Development
See other posts from Game Development
or by Anomaly
Published on 2014-05-10T20:01:00Z
Indexed on
2014/06/13
3:43 UTC
Read the original article
Hit count: 215
I have made my own C# classes in Unity, is there any way I can access these classes 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 that class:
string str=testClass.myString;
Is this possible? If so, how? Or is there some other way to do this? In the end I basically want to communicate between my Android activity and the UnityPlayer object.
Thanks in advance.
EDIT: Ok so 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:
So 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.
© Game Development or respective owner