Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Can't access UnityTransport in NetworkManager.Singleton.

Discussion in 'Netcode for GameObjects' started by DaveKap, Jul 5, 2023.

  1. DaveKap

    DaveKap

    Joined:
    Mar 6, 2013
    Posts:
    94
    I'm on a brand new project, Unity 2022.3.2f1, went through the NGO walk-through found here:
    https://docs-multiplayer.unity3d.com/netcode/current/tutorials/get-started-ngo/
    Everything works great, I can see updates from both server and client, and can continue working on my prototype. However, before I continue work, I wanted to see this project in action across an actual network. According to the page here:
    https://docs-multiplayer.unity3d.com/netcode/current/components/networkmanager/
    I'm supposed to programmatically access the UnityTransport component of the NetworkManager (and thus let the client set an IP address to find a server at) by a pretty simple GetComponent call. Unfortunately, when I try to do this, Visual Studio says:
    Error CS0246 The type or namespace name 'UnityTransport' could not be found (are you missing a using directive or an assembly reference?)

    What am I missing here? I feel as though perhaps there is either something missing in the package import process or there's something missing in the Walk-through. Any help would be appreciated.
     
  2. DaveKap

    DaveKap

    Joined:
    Mar 6, 2013
    Posts:
    94
    In classic rubber duck fashion, I discovered the answer by simply accepting Visual Studio's suggestion that I include Unity.Netcode.Transports.UTP at the top alongside Unity.Netcode. This seems to work but begs the question, why isn't this in the documentation? If it is, it doesn't come up in the documentation's search function, which is a problem.
     
  3. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    426
    Hi @DaveKap , it seems that you solved your issue by referencing the Transport namespace in your code.
    That's a basic C# workflow that is not multiplayer (or even Unity)-specific at all, which is why it is not included in the documentation.
    To clarify: if the multiplayer-specific documentation included things you're already supposed to know when working in C#, it would have a lot of noise that would hide the multiplayer-specific information, making the documentation hard to navigate.