金铉Unity插件库 Unity版本2018.4.32f 目前包含本地化存储功能(根据类名存储读写),TCP客户端监听类型功能
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using UnityEngine;
public class UDPPrinter : MonoBehaviour
{
private UDPUtility udpUtil;
// Start is called before the first frame update
void Start()
{
udpUtil = new UDPUtility("127.0.0.1", 20000);
udpUtil.sendData("hello everyone!");
}
// Update is called once per frame
void Update()
{
if (udpUtil != null && !"".Equals(udpUtil.getReceivedValue()))
{
/*GameObject item = Instantiate(tcpMsgItem, tcpMsgContent);
item.GetComponentInChildren<Text>().text = tcpUtil.receivedData.Value;
this.GetModel<TCPEventModel>().onDataRecived.Invoke(tcpUtil.receivedData.Value);*/
Debug.Log(udpUtil.receivedData.Value);
}
}
private void OnDestroy()
{
if (udpUtil.reciveT != null && udpUtil.reciveT.ThreadState == ThreadState.Running)
{
udpUtil.reciveT.Abort();
}
}
}