Search Unity

  1. Tune in to get all the latest Unity news live from Berlin on June 19, 6pm CEST. Set up a YouTube reminder!
    Dismiss Notice
  2. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  3. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Create a custom native network plugin

Discussion in 'Multiplayer Networking' started by unity_iKCco7B3xA1Ejg, Jun 14, 2018 at 9:20 AM.

  1. unity_iKCco7B3xA1Ejg


    Hi guys :) I'm a beginner with Unity!
    Today, I need some help to create a native plugin for implement my own network-api in C.
    Im familiar to TCP networks, and dont use the unity network API is a choice.

    My question is mostly related to the threads. My network plugin will work on another thread than the unity main thread. I heared somewhere that "unity doesn't love callbacks that happen outside its main thread, so you'll need some sort of queueing mechanism".

    Indeed, i was about to build my protocol; deserialized packets holded in structures that will be in some callback signatures. e.g void onFooBarMessage(size_t client_id, struct foo_bar_msg_t *msg). This callback will be finally defined from the unity C# and called by my network when receiving the concerned packet.

    It seems to be a bad practice for some multithread-rendering problems. So, is there anything unity built-in for that kind of problem? I discovered that may solve the issue but, is this function callable from a native plugin ?

    My idea is to keep defining callbacks in C#, registering them into my plugin, and then execute them with IssuePluginEvent().

    Thanks. Romain
  2. Joe-Censored


    Mar 26, 2013