Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.IO.Ports;
- using System.Threading;
- using UnityEngine.UI;
- public class LEDSONOFF : MonoBehaviour
- {
- public Animator anim;
- private SerialPort serial = new SerialPort("COM3",9600);
- public GameObject QUESTIONS;
- void Start()
- {
- anim.SetBool("butclose", false);
- serial.Open();
- QUESTIONS.gameObject.SetActive (false);
- }
- void Update()
- {
- readdata();
- //Debug.Log(serial.ReadByte());
- }
- void startANIM()
- {
- if (anim.GetBool("butclose") == false)
- {
- anim.SetBool("butclose", true);
- }
- }
- void readdata()
- {
- if (serial.ReadByte() == 8)
- { startANIM();
- QUESTIONS.gameObject.SetActive (false);
- Debug.Log("konpka");}
- if (serial.ReadByte() == 9)
- { Debug.Log("DEVYAT");
- }
- if (serial.ReadByte() ==5)
- { Debug.Log("pYAT");}
- }
- void OnMouseDown()
- {
- anim.SetBool("butclose", false);
- anim.SetTrigger("click1can");
- QUESTIONS.gameObject.SetActive (true);
- if (serial.IsOpen == true)
- {
- serial.Write("A");
- Debug.Log("SEND A");
- }
- if (serial.IsOpen == false)
- {
- serial.Open();
- serial.Write("A");
- }
- }
- }
Add Comment
Please, Sign In to add comment