// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.S)) { GameObject g = GameObject.FindGameObjectWithTag("SunLightObject"); sunLightScript = g.GetComponent <timeWalkDayNightToggle>(); // accesses the bool named "nowIsDay" and changed its value. sunLightScript.nowIsDay = false; } }
private void ToggleNight() { if (dayNightRef == null) { dayNightRef = FindObjectOfType <timeWalkDayNightToggle>(); } if (dayNightRef != null) { dayNightRef.ToggleDayNight(); } }