我想在Unity项目中使用C#插件.该插件应该充当服务器,它将从客户端获取值,以便我能够使用这些值进行进一步处理.问题是服务器有无限循环.无限循环导致Unity挂起.怎么办呢?
编辑:我附加了服务器程序的代码片段.在我看来,有两点可能导致问题.无限循环和程序暂停的点,如代码所示:
void networkCode()
{
// Data buffer for incoming data.
byte[] bytes = new Byte[1024];
// Establish the local endpoint for the socket.
// Dns.GetHostName returns the name of the
// host running the application.
IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 1755);
// Create a TCP/IP socket.
listener = new Socket(ipAddress.AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
// Bind the socket to the local endpoint and
// listen for incoming connections.
try
{
listener.Bind(localEndPoint);
listener.Listen(10);
// …Run Code Online (Sandbox Code Playgroud) 如何在我的 Android Studio 项目中导入 BoofCV?我已经看过这里了。我完全困惑了。请为我提供分步指南。我感谢您的帮助。
我可以使用以下方法检测何时按下后退按钮:
@Override
public void onBackPressed() {
//Do my thing
}
Run Code Online (Sandbox Code Playgroud)
但现在我想检测后退按钮的释放时间.我怎样才能做到这一点?我无法找到任何onBackReleased()我可以覆盖的方法来做我的事情.