Legacy Documentation: Version 2018.2 (Go to current version)
LanguageEnglish
  • C#

NetworkConnection.lastError

public Networking.NetworkError lastError;

Description

The last error associated with this connection.

Retrieve the last error that occurred on the connection, this value is set every time an event is received from the NetworkTransport.

In the following example, OnServerDisconnect is overridden from NetworkManager:

using UnityEngine;
using UnityEngine.Networking;

public class ExampleScript : NetworkManager { public override void OnServerDisconnect(NetworkConnection conn) { if (conn.lastError != NetworkError.Ok) { if (LogFilter.logError) { Debug.LogError("ServerDisconnected due to error: " + conn.lastError); } } } }
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答