我用团结创造了我的配对课程。这一切都在PC上工作正常,我很容易创建一个没有问题的匹配。当我尝试为iOS创建匹配时出现问题。
当我尝试创建新匹配时,我在Xcode上遇到了这个错误:
ArgumentNullException: Argument cannot be null.
Parameter name: baseUri
at System.Uri.Merge (System.Uri baseUri, System.String relativeUri) [0x00000] in <filename unknown>:0
at UnityEngine.Networking.Match.NetworkMatch.ListMatches (UnityEngine.Networking.Match.ListMatchRequest req, UnityEngine.Networking.Match.ResponseDelegate`1 callback) [0x00000] in <filename unknown>:0
(Filename: currently not available on il2cpp Line: -1)
以下是用于克隆匹配的代码:
void Start()
{
networkMatch = gameObject.AddComponent<NetworkMatch>();
}
private void OnMatchCreate(CreateMatchResponse matchResponse)
{
if (matchResponse.success)
{
NetworkServer.ClearLocalObjects ();
NetworkServer.ClearSpawners ();
NetworkServer.SetAllClientsNotReady ();
Debug.Log("Create match succeeded");
matchCreated = true;
Utility.SetAccessTokenForNetwork(matchResponse.networkId, new NetworkAccessToken(matchResponse.accessTokenString));
NetworkServer.Listen(new MatchInfo(matchResponse), 9000);
UnityEngine.Networking.NetworkManager.singleton.StartServer(new MatchInfo(matchResponse));
}
else
{
Debug.LogError ("Create match failed");
}
}
这里有什么问题?
答案 0 :(得分:2)
经过调查,我找到了解决这个问题的方法:
最终代码:
void Start()
{
networkMatch = gameObject.AddComponent<NetworkMatch>();
networkMatch.baseUri = new System.Uri("https://mm.unet.unity3d.com/");
}
网址是Unity提供的默认网址