I’m trying to create new RelayServerData and it says “CS1729: ‘RelayServerData’ does not contain a constructor that takes 2 arguments” although it is the same code that is used in documentation Using Unity Relay | Unity Multiplayer.
I’m using Unity 6, Multiplayer Services 1.0.2, Multiplayer Tools 2.2.1, NGO 2.1.1 and Unity Transport 2.3.0.
If you are using the Multiplayer Services SDK (com.unity.services.multiplayer), you can use AllocationUtils.ToRelayServerData(allocation, connectionType) to build the RelayServerData model.
This is within the Unity.Services.Relay.Models namespace.
You can pass it in the NetworkManager.Singleton.GetComponent().SetRelayServerData() method.
Even i am getting this exception after migrating from relay to Multiplayer i found this in Unity Docs from Migrating to Multiplayer (Section) and i update a little bit , this is working absolutely fine for me
Hey Eric, thank you so much for your post. I have a small follow up question - I’m following youtube tutorials and googling different things to figure out how to use these tools and often they will be a bit out of date. Is there a good way for me to figure out when a change like this (The deprecation / removal of a constructor for example) has been made and an alternative has been suggested? I spent like 6 hours trying to figure out what was wrong with my relay connection until I stumbled upon this post.
Hey Arthur, I appreciate the link. The problem here is that any changes to RelayServerData (The elimination of the 2 parameter constructor) has not been included in the ChangeLog. I searched for RelayServerData in that link that you posted, and nothing popped up. Am I looking in the right place?
Indeed, that is missing from the changelog. The 2 parameter constructor is available when using the Relay SDK, however it didn’t make it into the Multiplayer SDK. AllocationUtils.ToRelayServerData was added when the package was still in experimental state (prior to 1.0.0), now that the API is stable (post 1.0.0) any change, removal and addition will be added to future changelog
Thank you, I appreciate that. I guess what I’m trying to ask is, is there some way I might be able to search, some way I might be able to figure out without explicitly asking if something I’m trying to use has been deprecated, if there is an alternative? Like in this case? Like is there some Visual Studio search function or should I build an LLM that points at the entire code base or something?
Hi @JPMcWhiskers ,
Now that the Multiplayer SDK hit version more than 1.0.0, any deprecation within the SDK will be noticed first using the obsolete attribute and hint towards any alternative. Any actual breaking changes (API changes, behavior changes, …) will require us to hit a 2.0.0 version.