using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; // add this for the clear button, to reset the board using Uduino; // add this for the uduino functions public class color : MonoBehaviour { private SpriteRenderer rend; // takes the renderer to change the circle color [SerializeField] private GameObject highlight; //gets the highlight // the x and y to send to the corresponding light of the arduino [Range(0,63)] public int x; [Range(0,31)] public int y; //calling other script to grab the pixel color matrixBoard mB; public GameObject gameobject; public int Restart; // for the clear button // Start is called before the first frame update void Start() { //get the components mB = gameobject.GetComponent(); rend = GetComponent(); // makes all circles black rend.color = Color.black; } //paints the circles the right color and sends a message to light up the corresponding led with the right color & sets the highlight to active void OnMouseOver(){ highlight.SetActive(true); if (Input.GetKey (KeyCode.W)){ Debug.Log("function has been called"); rend.color = mB.pixelColor; UduinoManager.Instance.sendCommand("draw", x, y, (mB.pixelColor[0] * 255), (mB.pixelColor[1] * 255), (mB.pixelColor[2] * 255)); } else { Debug.Log("entered without function active"); } } // makes the highlight inactive if the mouse leaves the circle void OnMouseExit(){ highlight.SetActive(false); } // clears the screen public void clear(){ SceneManager.LoadScene(Restart); } }