123456789101112131415161718192021222324252627282930313233343536 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlaygroundLightControl : MonoBehaviour
- {
- public Light directionalLight;
- public Material daySkybox;
- public Material nightSkybox;
- // Start is called before the first frame update
- void Start()
- {
- int hour = System.DateTime.Now.Hour;
- float dayLightY = (12 - hour) * 10;
- if (hour < 6 || hour >= 18)
- {
- // night time
- directionalLight.transform.rotation = Quaternion.Euler(60, 0, 0);
- directionalLight.intensity = 0.67f;
- UnityEngine.RenderSettings.skybox = nightSkybox;
- }
- else
- {
- // day time
- directionalLight.transform.rotation = Quaternion.Euler(60, dayLightY, 0);
- UnityEngine.RenderSettings.skybox = daySkybox;
- UnityEngine.RenderSettings.ambientIntensity = 0.75f;
- }
- DynamicGI.UpdateEnvironment();
- }
- // Update is called once per frame
- void Update()
- {
-
- }
- }
|