- Home /
How put Android native code into c# unity
Hi everyone ... how i can put android native code into c# unity, i need access for example: list contact or camera from my phone... and then i need work with that.
something like:
using UnityEngine;
{IMPORT JAVA CODE}
public class NewBehaviourScript : MonoBehaviour {
void Start () {
{JAVA CODE}
}
}
thanks
Answer by whydoidoit · Oct 05, 2013 at 07:36 AM
There's no way to do that. You can include native code as a plugin if you have Pro (Desktop) or if you use Mobile platforms.
http://docs.unity3d.com/Documentation/Manual/PluginsForAndroid.html
You can access the camera using the Webcam class in Unity and there's bound to be a plugin already written on the Asset Store for getting what you need.
I found that ... this not allow me put a lot of native code sure?
void OnGUI () {
string somestring;
AndroidJavaClass jc= new AndroidJavaClass("com.example.pluginsample.$$anonymous$$ainActivity");
AndroidJavaObject jo = jc.GetStatic("instance");
somestring = jo.Call("Foo");
GUI.Label (new Rect (20, 20, 100, 20), somestring);
}
In Java Class:
public String Foo() {
return "Hello";
}
what do you thing about that ..,
You can access your own class presu$$anonymous$$g it's being loaded in the Android$$anonymous$$anifest.xml file - probably as an override to the normal Unity player...
i think use that and modify Android$$anonymous$$anifest.xml but i dont now .. :D look at more information
okey the other option is make a plugin java to c# ... okey i will make ... !