12345678910111213141516171819202122232425262728293031323334353637 |
- using LitJson;
- using System.Net;
- using System.Net.Sockets;
- using Unity.RenderStreaming;
- using Unity.RenderStreaming.Signaling;
- using UnityEngine;
- using UnityEngine.UI;
- public class UDPBroadcast : MonoBehaviour
- {
- private UdpClient udpClient;
- private IPEndPoint ipEndPoint;
- void Start()
- {
- udpClient = new UdpClient();
- ipEndPoint = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 1234);
- }
- void Update()
- {
- SendData();
- }
- public Camera ca;
- public Text t;
- void SendData()
- {
- string message = "hello World";
- byte[] data2 = System.Text.Encoding.ASCII.GetBytes(message);
- udpClient.Send(data2, data2.Length, ipEndPoint);
- }
- void OnDestroy()
- {
- udpClient.Close();
- }
- }
|