1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Experimental.Rendering;
- using UnityEngine.Rendering;
- public class HomeSunLight : MonoBehaviour
- {
- // Start is called before the first frame update
- public float rotationSpeed = 30f;
- public Transform rotateObj;
- public Transform targetObj;
- public Light rotateLight;
- public GameObject targetCamera;
- public Material daySkybox;
- public Material nightSkybox;
- void Start()
- {
- GameObject homeLight = GameObject.Find("Home Light");
- int hour = System.DateTime.Now.Hour;
- //hour = 7;
- float rotateAngle = (12 - hour) * 13;
- //print(rotateAngle);
- if (hour < 6 || hour >= 18)
- {
- // night time
- rotateLight.intensity = 0.1f;
- //targetCamera.GetComponent<Camera>().backgroundColor = new Color(22, 42, 113, 239);
- UnityEngine.RenderSettings.skybox = nightSkybox;
- UnityEngine.RenderSettings.ambientIntensity = 0.2f;
- UnityEngine.RenderSettings.reflectionIntensity = 0.2f;
- homeLight.GetComponent<Light>().intensity = 1f;
- }
- else
- {
- Debug.Log("day time");
- // day time
- rotateLight.intensity = 0.7f;
- //targetCamera.GetComponent<Camera>().clearFlags = CameraClearFlags.SolidColor;
- //targetCamera.GetComponent<Camera>().backgroundColor = new Color(139, 202, 255, 203);
- UnityEngine.RenderSettings.skybox = daySkybox;
- UnityEngine.RenderSettings.ambientIntensity = 0.9f;
- UnityEngine.RenderSettings.reflectionIntensity = 1f;
- homeLight.GetComponent<Light>().intensity = 0.4f;
- rotateObj.RotateAround(targetObj.transform.position, Vector3.forward, rotateAngle);
- }
- DynamicGI.UpdateEnvironment();
- }
- // Update is called once per frame
- void Update()
- {
-
- }
- }
|