Turn directional light at "night" ..

using UnityEngine;
using System.Collections;

public class daynight : MonoBehaviour {

	// Use this for initialization

	public Light dayNight;
	public float rychlostDne;

	// Update is called once per frame
	void FixedUpdate () {
		dayNight.enabled = true;

		dayNight.transform.Rotate (Vector3.right * rychlostDne * Time.deltaTime);
		if (dayNight.transform.rotation.x <= 230) {
			Debug.Log ("vypno");
			dayNight.enabled = false;


This doesn’t work as Unity handles angles in an awkward way. Just check if the dot product of the forward vector of the light and the global up vector is less than arccos(x), where is x is your desired space angle from the global up vector.


if (Vector3.Dot(Vector3.up, light.transform.forward) > Mathf.Acos(x)) {
    //Light enabled
} else {
    //Light disabled

As said earlier, x is the desired angle in radians from the y-vector in the Unity basis.