iOS本机版本的Unity Unet多人游戏问题

时间:2016-06-24 07:57:15

标签: ios xcode unity3d unity3d-unet

我用团结创造了我的配对课程。这一切都在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");
        }
    }

这里有什么问题?

1 个答案:

答案 0 :(得分:2)

经过调查,我找到了解决这个问题的方法:

  • 确保网络初始化发生在Start方法
  • 设置要用于匹配的mach URI。

最终代码:

void Start()
    {

        networkMatch = gameObject.AddComponent<NetworkMatch>();
        networkMatch.baseUri = new System.Uri("https://mm.unet.unity3d.com/");          
    }

网址是Unity提供的默认网址