How do I change Unity Transport IP Address and Port during runtime?

nvm got it, needed namespace “using Unity.Netcode.Transports.UTP” , then NetworkManager.GetComponent().ConnectionData.Address=“someString”;

1 Like

What about the port ?
I am trying
NetworkManager.GetComponent().ConnectionData.Port = ushort.Parse(PortNumberText.text)
where PortNumberText.text is the string of a TextMeshPro UI element
but Unity (more precisely C#) complains about the string format but I don’t understand why.
How did you do?

OK for some reasons it seems that there is an extra character at the end of the string when I get it from the input field TMPro text. Removing this extra character removes the error.

i love you thank you this worked

How to actually do that in mirror?

That’s out of date now, I tried it and it just didn’t work, the new function for this using the Unity Transport is:

NetworkManager.Singleton.GetComponent().SetConnectionData(targetIP, (ushort)7777);

Where targetIP can just be any string that is the IP, and the numbers following the ushort is how you set the port.