The fact that the PC does not have to say, after all, C # and C + + interactive article is enough, of course, I feel after a few toss. Almost all the games need to operate I have mastered (a variety of methods, all kinds of pits, do not understand the message can be asked. Although no one looked at all. haha
Needless to say, we're mainly talking about two big platforms--ios and android--interacting with Unity's native code
Here is to go online search is all kinds of egg pain, for example, suppose to call Unity C # function, almost exclusively is to give Unitysendmessage method. Using this in the project is almost dead. That's a lot of complicated functions. You're the one with the broken function.
iOS is fine to say. Android is a pit, even if you want to interact with the Java code, in short, C + +-"Java-" C #. And in fact most of the time you do not need such a pain, direct C/C + +-"C # can be." Because C + + is nearly capable of operating all underlying resources. Of course, individual requirements exceptions
Business
typedef struct PARAMETER { int A; int b;} param;typedef void (*callback) (param* p); void TestFunc (CallBack cb) { Param p; P.a = ten; P.B =; CB (&P);}
extern "C" such details are not much to say, because I directly built a. C file so do not need this tag, here directly with the typical callback function to do the example, because of the callback. You don't have to think about how to use C/C + + or vice versa, because this example actually includes the exchange of information
public class Newbehaviourscript:monobehaviour { [StructLayout (layoutkind.sequential)] struct Parameter { public int A; public int b; } delegate void CallBack (IntPtr param); [DllImport ("TestLib")] static extern void TestFunc (CallBack cb); [Monopinvokecallback (typeof (CallBack))] static void Callbackfunc (IntPtr param) { var p = (Parameter) marshal.ptrtostructure (param, typeof (Parameter)); Debug.Log ("A:" + P.a + "B:" + p.b); } Use the This for Initializationvoid Start () { TestFunc (callbackfunc);} Update is called once per framevoid update () {}}
Notice key No, yes,
[monopinvokecallback (typeof (CallBack))]
this tag. Without this tag, the callback will not succeed.
android Protection C # also mentioned in the previous article that although individuals do not know about security assumptions, the only hint is to use Coroutine coroutine
Unity uses C/ The ultimate cross-platform solution (Pc,ios,android, and a platform that supports C + +)