22 lines
604 B
C#
22 lines
604 B
C#
|
using UnityEngine;
|
|||
|
|
|||
|
public class DayNightCycle : MonoBehaviour
|
|||
|
{
|
|||
|
public Light sun;
|
|||
|
public float dayDuration = 120f; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
private float currentTime = 0f;
|
|||
|
|
|||
|
void Update()
|
|||
|
{
|
|||
|
currentTime += Time.deltaTime;
|
|||
|
float timePercentage = currentTime / dayDuration;
|
|||
|
float sunAngle = Mathf.Lerp(0, 360, timePercentage);
|
|||
|
sun.transform.rotation = Quaternion.Euler(new Vector3(sunAngle - 90, 170, 0));
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if (currentTime >= dayDuration)
|
|||
|
{
|
|||
|
currentTime = 0f;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|