Search Unity

using UnityEngine.Networking dll in your own c# project

Discussion in 'Multiplayer' started by Optimus_Prime, Jun 24, 2017.

  1. Optimus_Prime

    Optimus_Prime

    Joined:
    Apr 15, 2015
    Posts:
    34
    hi,

    I have made a prototype of my game using the LLAPI, its a simple turnbased game with 5 players max per room.

    Can i use the unity networking dll in a .NET Core application? Lets say for example I want to use the Unity Networking DLL in a "asp.net core web api" or console app that I can host on Microsoft Azure and get my game clients to connect to that server. If I cannot do this, use unity networking dll outside of unity, Can I run my server headless (Windows) on Microsoft Azure? How do you even run headless on windows ? Basically I want my game server to be hosted on "azurewebsites.net" and my android clients to connect to this url.

    I am trying to make this question descriptive as possible because most of my problems were solved by just browsing this forum and trying out code, If I need to make my question more clear / descriptive, please let me know.
     
  2. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    You can compile the Networking DLL yourself. Or run headless. Both work. To compile it yourself.
    https://bitbucket.org/Unity-Technologies/networking
    And to run headless. Just start the program with parameters -nographics and -batchmode
     
  3. Optimus_Prime

    Optimus_Prime

    Joined:
    Apr 15, 2015
    Posts:
    34
    Thank you for the reply TwoTen, So if I compile the code myself and just reference the dll in my .net core project, do I just start a Task called Update() and just call that from static Main() ? and all my networking messages will come through to my own Update()? do I not need to pass anything into the method? What if I wanted to add the dll to a web api core project, do I just start another Task from the controller ? what will the api controller take in as a message? Im basically trying to understand how to deploy my unity server to Microsoft Azure.
     
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Why would you need a Update method?
     
  5. Optimus_Prime

    Optimus_Prime

    Joined:
    Apr 15, 2015
    Posts:
    34
    how else would I get messages from the clients and how would I send messages back to connected clients, My understanding and the examples I followed was to accept messages in the update method using NetworkTransport.Receive which will give me the connectionID I need to work with. I dont think I fully grasp the concept of adding the networking dll to my web api project and getting a unity client to connect and communicate with it.
     
  6. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    You get a packet, process that and then send the information back. No need for an update method really. But it should all work.
     
  7. Optimus_Prime

    Optimus_Prime

    Joined:
    Apr 15, 2015
    Posts:
    34
    ok I am going to try a simple example by adding a reference to the networking dll and I will keep you updated on my progress, Thank you
     
  8. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Best of luck.
     
  9. Optimus_Prime

    Optimus_Prime

    Joined:
    Apr 15, 2015
    Posts:
    34
    so I worked on using the dll within a .net core console app and I was not successful due to the version of .net core I had installed, so I thought before installing the latest version of core let me try a standard .net console application, I added the dll and I was unsuccessful. I will just use unity projects for now till I have some time to figure out the dll with an external solution, but thank you for your help.

    Anyways I have decided to find a cheap vps server and do the following from this article :
    https://noobtuts.com/unity/unet-server-hosting
     
  10. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Personally I suggest not using .net Core. Just use .net Framework instead and if you need to run on linux. Compile with Mono
     
  11. tz2989

    tz2989

    Joined:
    Sep 18, 2017
    Posts:
    1
    Not to hijack the thread, but I pulled the code from bitbucket, compiled it, and added the reference to my standalone project, and I am getting SecurityExceptions which appears to be due to attempting to running the lib outside of Unity.

    Am I missing something, or are you still unable to use the UnityEngine.Networking library outside of unity?
     
  12. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    I think the only thing you can actually use is the Server DLL which you can get by asking Aabramachev. I do belive it does not work for linux though.