How exactly PUN is integrated into Unity?

Hello, I want to build a plugin for iOS in Unity and I was wondering how all the Photon C# code was relying on libPhotonSocketPlugin.a ?

According to Unity documentation, there should be some C# file that do the wrapping over the native code (libPhoton*.a is native code right, looks like C++?), I was not able to find such wrapper, kind like [DllImport("__Internal")] ...

So I was wondering if I was missing something or if you guys could give me more details about how it is integrated?

Thanks,
Don T.

Comments

  • We only need the DllImport statements when we use the native socket lib. PUN takes care of doing this for you, so you don't really need to worry about this.
    Do you have issues with this or are you looking for some help to wrap your own native libs?
  • Tobias, so that's what I'm looking for: where in PUN are the DllImport (to use the native lib)?? Or are you saying that PUN doesn't rely on the native lib at all, I assume not?

    Basically, I'm newbies in Unity Plugins and plan do to my own (don't worry not related to PUN) and wanted to understand how PUN is working to do the same design pattern.

    Thanks
    Don T.
  • I was just following Unity's examples:
    http://docs.unity3d.com/Manual/Plugins.html
    Any C# related tutorial also applies, as Unity is just using standard C# for this.

    The code where we DllImport things is not in PUN source but in the dll, so I can not properly give you advice on it. Sorry.
  • Hello Tobias, oh great that's answer my question :), fair enough. So PUN come with generic C# bundled in a DLL, which take care of the DllImport to access the native code, I see. It's smart, instead of having this a glue code directly as source in Unity, but I assume this brings value mainly if you want to "hide" to developers how to access the native code directly, which can be still found of course by listing symbol on the native library and so on, but figuring out the signature and so on is more complicated.

    Thanks,
    Don T.
  • Exactly. In our case, a benefit of the dll is also that we don't have SO many files in source in our package. We assume that the lower level "just works" and that anything higher level in PUN is open to look at and modify. It's our way to say "you don't have to care about this", if you will.

    I hope the link helped a bit. When I really tried this and had some help of your C++ guru (thanks, Ludi), this wasn't too difficult after all.