fork download
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.IO.Ports;
  4. using System;
  5.  
  6. public class RS232 : MonoBehaviour {
  7.  
  8. SerialPort sp = new SerialPort("COM2", 9600);
  9.  
  10. // Use this for initialization
  11. void Start () {
  12. // sp = new SerialPort("COM10", 9600);
  13. sp.ReadTimeout=100;
  14. sp.Open();
  15. }
  16.  
  17. // Update is called once per frame
  18. void Update () {
  19. try{
  20. print (sp.ReadLine());
  21. }catch(Exception e){};
  22. }
  23. }
  24.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(1,7): error CS0246: The type or namespace name `UnityEngine' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty