###実現したいこと
UnityでUDPを使って画像受信するシステムを作りたいと思っています。
メッセージの受信はネット情報を参考にしてできるようになりましたが、画像受信の仕方がわかりません。
プログラミング初心者のため、全くどうしていいのかわからないため教えて頂きたいです。
よろしくお願い致します。
###メッセージを受信するプログラム
UDPClient.cs
1using UnityEngine; 2using System.Net.Sockets; 3using System.Text; 4 5public class UDPClient : MonoBehaviour 6{ 7 // broadcast address 8 public string host = "127.0.0.1"; 9 public int port = 50000; 10 private UdpClient client; 11 12 void Start () 13 { 14 client = new UdpClient(); 15 client.Connect(host, port); 16 } 17 18 void Update () 19 { 20 } 21 22 void OnApplicationQuit() 23 { 24 client.Close(); 25 } 26}
using UnityEngine; using System.Collections; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; public class UDPReceive : MonoBehaviour { //address information int LOCA_LPORT = 50000; static UdpClient udp; Thread thread; void Start () { udp = new UdpClient(LOCA_LPORT); thread = new Thread(new ThreadStart(ThreadMethod)); thread.Start(); } void Update () { } void OnApplicationQuit() { thread.Abort(); } private static void ThreadMethod() { while(true) { IPEndPoint remoteEP = null; byte[] data = udp.Receive(ref remoteEP); string text = Encoding.ASCII.GetString(data); Debug.Log(text); } } }