小编Boo*_*zzz的帖子

Unity3d和UdpClient

我想使用套接字将UDP包读入Unity3d.UDP包由另一个C#应用程序发送,该应用程序不是Unity应用程序.因此,我将以下脚本(原始源)附加到我的一个游戏对象中.不幸的是,当我运行我的项目时,Unity会冻结.谁能告诉我为什么?

using UnityEngine;
using System.Collections;
using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Text;

public class InputUDP : MonoBehaviour
{
    // read Thread
    Thread readThread;

    // udpclient object
    UdpClient client;

    // port number
    public int port = 9900;

    // UDP packet store
    public string lastReceivedPacket = "";
    public string allReceivedPackets = ""; // this one has to be cleaned up from time to time

    // start from unity3d
    void Start()
    {
        // create thread for reading UDP …
Run Code Online (Sandbox Code Playgroud)

c# sockets mono unity-game-engine

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

mono ×1

sockets ×1

unity-game-engine ×1