// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Mouse0)) { Ray ray = GetComponent <Camera>().ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.transform.tag == "Light") { ChangeLight light = hit.transform.GetComponent <ChangeLight>(); light.onClick(); } //print("Tag: " + hit.transform.tag); } } }
// Use this for initialization void Start() { isSimulating = false; xDuration = totalDuration / 2; xGreen = true; Level thisLevel = (Level)GameObject.FindObjectOfType (typeof(Level)); if(thisLevel != null){ gameObject.tag = thisLevel.levelObjTag; } else{ gameObject.tag = "simMode"; } typeOfIntersection = Constants.emptyIntersection; XLight = (ChangeLight)intersection.Find ("XLight").GetComponent (typeof(ChangeLight)); YLight = (ChangeLight)intersection.Find ("YLight").GetComponent (typeof(ChangeLight)); switch (typeOfIntersection) { case Constants.streetlight: startStreetlight (); break; case Constants.stopsign: startStopsign (); break; default: startNothing(); break; } }