Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using UnityEngine;
- using System.IO.Ports;
- public class ReadUSBChangeShader : MonoBehaviour {
- private Renderer holoRenderer;
- SerialPort sp; //whatever COM arduino uses
- private void Awake(){
- try{
- sp = new SerialPort("COM3", 9600);
- }
- catch(System.Exception ){
- }
- }
- void Start(){
- try{
- sp.Open();
- sp.ReadTimeout = 1;
- }
- catch(System.Exception){
- }
- }
- void Update () {
- if (sp.IsOpen)
- {
- try{
- sp.ReadByte(); // DO WHATEVER THE *YOU WANT
- }
- catch (System.Exception){
- }
- }
- else{
- if(Input.GetKeyDown(KeyCode.R)){
- //Do something
- Debug.Log("lee alterno");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement