using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEditor.Experimental; using UnityEngine; public class SunMovement : MonoBehaviour { // Start is called before the first frame update public float rotationSpeed = 30f; public Transform rotateObj; public Transform targetObj; //public Transform targetCamera; public Light rotateLight; public Material daySkybox; public Material nightSkybox; void Start() { int hour = System.DateTime.Now.Hour; float rotateAngle = (12 - hour) * 13; //print(rotateAngle); if (hour < 6 || hour >= 18) { // night time //rotateLight.color = new Color(0, 0, 0.5f, 1); rotateLight.intensity = 0.7f; rotateLight.spotAngle = 50; UnityEngine.RenderSettings.skybox = nightSkybox; UnityEngine.RenderSettings.ambientIntensity = 0.3f; UnityEngine.RenderSettings.reflectionIntensity = 0.2f; } else { // day time UnityEngine.RenderSettings.skybox = daySkybox; UnityEngine.RenderSettings.ambientIntensity = 0.9f; UnityEngine.RenderSettings.reflectionIntensity = 1f; rotateObj.RotateAround(targetObj.transform.position, Vector3.forward, rotateAngle); } DynamicGI.UpdateEnvironment(); //Debug.Log(rotateObj.transform.position); } // Update is called once per frame void Update() { } }