Client Support

Unity3D plug-in

iFun Engine supports Unity3D. You can find a plug-in without the packet encryption feature on GitHub: https://github.com/iFunFactory/engine-plugin-unity3d/.

If you are a paying customer, you can request one with packet encryption enabled by emailing iFun Engine support.

Warning

If you are planning to use Google Protobuf along with Unity3D, your client may require an extra build step. Please refer to Unity3D with Google Protobuf.

Unity3D with Google Protobuf

Unfortunately, you cannot directly use Protobuf-net’s C# output due to restrictions on iOS and Android.

Otherwise, you will see a crash message coming from libmono’s JIT compiler like below when reading Protobuf extension through GetExtension().

F/mono    (1021): * Assertion at mini-arm.c:2595, condition `pdata.found == 1' not met
F/libc    (1021): Fatal signal 11 (SIGSEGV) at 0x0000600d (code=-6), thread 1033 (UnityMain)

To work around the issue, you should AOT-build serialization and deserialization rather than rely on mono’s JIT.

Required files

  • Unity3D or mono package (e.g., on Linux)
  • protobuf-net.dll: for Unity3d. You can find it from Unity Asset Store.
  • protogen and precompile programs from protobuf-net.
  • funapi/network/fun_message.proto packaged in iFun Engine Unity 3D plug-in.

Steps demonstrated below is on Windows, but you can do the same steps on other mono-compatible OSes, too. You can find template scripts to simplify the steps at the end of this explanation.

Converting .proto into .cs

protogen -i:path\to\fun_message.proto -o:temp\fun_message.bin
protogen -i:path\to\your_messages.proto -o:temp\your_messages.bin
REM If you have more than one proto files, repeat on them.

protogen -i:temp\fun_message.bin -o:temp\fun_message.cs -p:detectMissing
protogen -i:temp\your_messages.bin -o:temp\your_messages.cs

Generating a DLL file containing Protobuf messages

Output directory must be under Assets/ or its sub-directory. We need to generate a DLL file containing Protobuf message definitions. The DLL file will be used by iOS and Android.

REM gcms is in Unity3D.
call gmcs -target:library -unsafe+ ^
    -out:path\to\Assets\messages.dll ^
    /r:path\to\protobuf-net.dll ^
    temp\*.cs

Generating a serializer DLL

Next, we generate a DLL for FunMessageSerializer that performs actual reads and writes. Please note that the output directory should be either under Assets/ or its subdirectory.

precompile path\to\Assets\messages.dll ^
    -o:path\to\Assets\FunMessageSerializer.dll ^
    -t:FunMessageSerializer

Final outputs

You now have two DLL files as follows:

  • messages.dll
  • FunMessageSerializer.dll

Please make sure you need to repeat the steps whenever you make a change in your proto file.

Please email iFun Engine support if you have any difficulties.

Tip

To simplify your life, we have template scripts. Please download and customize.

Please refer to this for the required directory structure. You can use proto-files and protobuf-net directories.

Cocos2d-X plug-in

Coco2d-X is also supported. You can find its plug-in also on Github: https://github.com/iFunFactory/engine-plugin-cocos2dx/.

As with the Unity3D plug-in, please email iFun Engine support to get one with the encryption feature on.

Unreal4 plug-in

We are working on it, and it will be available shortly. Please be patient.