Search Unity

Third Party Is there a way to change the port via script in Mirror

Discussion in 'Multiplayer' started by TheOtherUserName, Oct 24, 2021.

  1. TheOtherUserName

    TheOtherUserName

    Joined:
    May 30, 2020
    Posts:
    136
    Idk if this should have been posted in scripting but since the question centers around Mirror I posted it here.

    I have made my own HUD but I also want to let the Player change the port he is connecting to but I have struggled to find anything on that topic.
    The documentation didn't offer any help so if someone knows the answer I would be glad.
     
  2. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    660
    The port is on the transport component of the NetworkManager, you can change it in Unity editor or via a script.

    This is an example of changing the port for the Telepathy Transport:

    Code (CSharp):
    1.         GameObject.FindObjectOfType<NetworkManager>().GetComponent<TelepathyTransport>().port = 7000;