using System; using UnityEngine; namespace Script { public class test : MonoBehaviour { private ModbusTcpClient client; private void Start() { hh(); } async void hh() { // 使用 client = new ModbusTcpClient(); await client.ConnectToServer(); Debug.Log("123"); } private void OnDestroy() { client.CloseConnection(); } } }