Search Unity

Editing Unity Networking Scripts

Discussion in 'Multiplayer' started by TwoTen, Mar 8, 2017.

  1. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Hello!
    I am currently attempting to integrate the host migration system that UNET provides. However. It currently uses some OnGUI methods that could be skipped and made automatic by putting everything in the update method instead of on button presses.

    The default network manager looks like this:
    https://bitbucket.org/Unity-Technol...anager.cs?at=5.6&fileviewer=file-view-default

    And my version I would like to use is something similar to this:
    https://hastebin.com/edisazeful.cs (Wrote this very quickly as an first attempt).
    But it seems like the story is more complicated than that.

    I am unable to simply make a script with the same class name as this line:
    Code (CSharp):
    1. NetworkManager.singleton.SetupMigrationManager(this);
    requires the class to be from the DLL. So I thought I would simply compile the DLL with my changes. But it's not that simple either as I just got a load of problems when trying to replace the default DLL with mine. What approach should I take to accomplish my fairly simple goal?


    Very happy for replies.
     
  2. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    244
    so basically the approach is this -
    1. download the unet source code from bitbucket for the version of unity you're using.
    2. open up the source code in monodevelop (i believe it comes with a solution file you can open. if not, make one)
    3. make changes as necessary
    4. build in monodevelop. this makes a few DLLs in the output folder.
    5. copy/paste the DLLs into your Unity application folder. i think there's a built in hookin MonoDevelop to do this for you automatically after building, but I had trouble getting this working myself. a simple bat/shellscript can move these for you pretty quickly though.
      1. on windows, they go in C:\Program Files\Unity\Editor\Data\UnityExtensions\Unity\Networking
      2. on mac, i forget the exact path, but it's something like /Applications/Unity.app/Resources/Editor/Data/UnityExtensions/Unity/Networking
    6. if you alt-tab back into unity, you should now see the compile wheel spinning. when it's done, you should now be using your modified UNET code. if you need to build your app, and not run from the editor, you're going to want to restart unity at this point, otherwise you might get some compile errors.
    keep in mind that making changes to UNET's source code will add a layer of complexity if you decide to upgrade your Unity version. you'll have to look at the UNET code on bitbucket for the new version of unity, and reconcile any differences with your changes.