Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region bibliotecas
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.IO.Ports;
- #endregion
- public class Interruptor : MonoBehaviour
- {
- #region Variaveis
- string valor;
- string mensages;
- [SerializeField] GameObject luz;
- public SerialPort sp = new SerialPort("COM3", 9600);
- #endregion
- #region Metodos Unity
- void Awake()
- {
- sp.Open();
- }
- void Update()
- {
- valor = sp.ReadLine();
- if(valor == "0")
- {
- Desativado();
- }
- if(valor == "1")
- {
- Ativado();
- }
- }
- void OnApplicationQuit()
- {
- sp.Close();
- }
- #endregion
- #region Metodos privados
- void Ativado()
- {
- print("Ativado");
- luz.SetActive(true);
- }
- void Desativado()
- {
- print("Desativado");
- luz.SetActive(false);
- }
- #endregion
- #region Comentarios
- /*
- ■
- ■
- ■
- ╔══════════════════════════════════════════════════════|>
- ║ -
- ║
- ║ FB -> fb.com/NuKe.Pedro.Arthur
- ║ IG -> @pedro.arthur.pa
- ║
- ║
- ╚══════════════════════════════════════════════════════|>
- ■
- ■
- ■
- */
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement