Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System;
- using System.IO.Ports;
- using System.Collections;
- using System.Collections.Generic;
- class PlayerStream
- {
- public int playerID;
- public SerialPort stream;
- public string recievedData = "EMPTY";
- }
- public class ControllerDetection : MonoBehaviour {
- List<PlayerStream> streams = new List<PlayerStream>();
- // Use this for initialization
- void Start () {
- for (int i = 1; i < 10; i++)
- {
- SerialPort stream = new SerialPort("COM"+i, 115200);
- try
- {
- stream.Open();
- Debug.Log("COM" + i + " is open.");
- PlayerStream ps = new PlayerStream();
- ps.playerID = i;
- ps.stream = stream;
- streams.Add(ps);
- }
- catch
- {
- Debug.Log("COM" + i + " is not open.");
- }
- }
- foreach (PlayerStream ps in streams)
- {
- Debug.Log("Got player "+ps.playerID);
- }
- }
- // Update is called once per frame
- void Update () {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement