質問編集履歴

1

sendとreceiveしてるコード添付漏れてたので追記しました

2020/07/10 08:23

投稿

marumaru0303
marumaru0303

スコア1

test CHANGED
File without changes
test CHANGED
@@ -318,6 +318,150 @@
318
318
 
319
319
 
320
320
 
321
+ ```C#
322
+
323
+ using System.Collections;
324
+
325
+ using System.Collections.Generic;
326
+
327
+ using UnityEngine;
328
+
329
+ using System.Text;
330
+
331
+ using System.Net;
332
+
333
+ using System.Net.Sockets;
334
+
335
+ using System.Threading;
336
+
337
+ using UnityEngine.UI;
338
+
339
+
340
+
341
+
342
+
343
+ public class UDP_button_Manager : MonoBehaviour
344
+
345
+ {
346
+
347
+ public Text receiveText;
348
+
349
+
350
+
351
+ private UDP commUDP = new UDP();
352
+
353
+ private bool sendSwitch = false;
354
+
355
+ private bool receiveSwitch = false;
356
+
357
+
358
+
359
+ private void Start()
360
+
361
+ {
362
+
363
+ commUDP.init(8887, 9001, 9000);//(送信用ポート番号、送信先ポート番号、受信用ポート番号)
364
+
365
+ receiveText.text = "Test";
366
+
367
+ }
368
+
369
+
370
+
371
+ private void Update()
372
+
373
+ {
374
+
375
+ if (receiveSwitch)
376
+
377
+ {
378
+
379
+ receiveText.text = commUDP.rcvMsg;
380
+
381
+ }
382
+
383
+ }
384
+
385
+
386
+
387
+ public void wifiSend()
388
+
389
+ {
390
+
391
+ if (sendSwitch == false)
392
+
393
+ {
394
+
395
+ sendSwitch = true;
396
+
397
+ commUDP.send("ぽ");
398
+
399
+
400
+
401
+ }
402
+
403
+ else
404
+
405
+ {
406
+
407
+ sendSwitch = false;
408
+
409
+ commUDP.send("め");
410
+
411
+
412
+
413
+ }
414
+
415
+
416
+
417
+ }
418
+
419
+
420
+
421
+
422
+
423
+ public void WiFiReceive()
424
+
425
+ {
426
+
427
+ if (receiveSwitch == false)
428
+
429
+ {
430
+
431
+ receiveSwitch = true;
432
+
433
+ commUDP.start_receive();
434
+
435
+
436
+
437
+
438
+
439
+ }
440
+
441
+ else
442
+
443
+ {
444
+
445
+ receiveSwitch = false;
446
+
447
+ commUDP.stop_receive();
448
+
449
+ }
450
+
451
+
452
+
453
+ }
454
+
455
+
456
+
457
+
458
+
459
+ }
460
+
461
+ ```
462
+
463
+
464
+
321
465
  ### 試したこと
322
466
 
323
467