Kaira Digital ArtsKaira Digital Arts
Sayfalar (23)Time Module

Time Module

Son güncelleme: 6 Ekim 2026

Bu sayfa henüz Türkçeye çevrilmedi, İngilizcesi gösteriliyor.

The clock. It advances the time of day, counts days, rotates the sun and switches between the sun and moon lights. Every other module reads its time, so if you drive the time from your own game code, this is the only module you have to talk to.

Inspector

  • Time Controls (always visible): Play and Pause, and the Dawn, Noon, Dusk and Midnight presets.
  • Time Progression: the current time on a day gradient bar, Day Speed with the 1x, 60x, 300x and 1000x presets, and the day counter with Set Day, Reset and Skip +1, +7 and +30 days.
  • Events: a timeline of the day, the day and night times, and the custom event times (+ Add Event).
  • Setup: runtime start options and the sun and moon lights.

Play in Time Controls runs the clock in Edit Mode as well. Days can complete in Edit Mode this way, so if you subscribe to OnDayCompletedEvent from your own editor-time code, check Application.isPlaying. The weather system ignores edit-mode day changes.

Clock

SettingDefaultDescription
enableTimeProgressiononMaster switch for the clock. Off, time stands still at currentTime
currentTime12Current hour of the day, 0 to 24
daySpeed60Speed multiplier, 0 to 1000. 1 is real time, 60 makes one game hour last one real minute. A day lasts 86400 / daySpeed real seconds
currentDay0Day counter
enableTimeOnRuntimeonForces time progression on when Play Mode starts, even if the clock was paused in the editor
useCustomStartTime, customStartTimeoff, 8Time the scene starts at in Play Mode

Day and night times

SettingDefaultDescription
dayStartTime6Day begins. Also the center of the day and night ambience crossfade
sunriseTime6When the sunrise event fires
sunsetTime18When the sunset event fires
nightStartTime20Night begins
customEventTimesNamed times of day (name, time, enabled) that the Events Module reacts to

These times decide IsDayTime(), IsNightTime() and when the events fire. They do not move the sun: the sun always crosses the horizon at 06:00 and 18:00.

Sun and moon lights

SettingDefaultDescription
sunLightThe directional light that is rotated. In the prefab this is MainLight
autoUpdateSunRotationonRotates the sun from the clock
sunRotationOffset170Compass direction of the sun's path, in degrees
autoToggleLightsByTimeonSwitches the sun light object on while the sun is above the threshold and off below it, every frame
sunLightOnHeightThreshold-0.05Sun height (the sine of its elevation, -0.4 to 0.4) where the lights switch. 0 is the horizon. Negative keeps the sun lit a little into twilight
moonLightOptional. A second directional light that is switched opposite to the sun: off by day, on at night

The prefab has one directional light. If you want direct moonlight at night, add a second directional light and assign it as Moon Light.

Public API

MemberDescription
void SetTime(float hours)Jump to a time of day, 0 to 24
float GetCurrentTime()Current hour, 0 to 24
float GetNormalizedTime()Current time as 0 to 1
string GetFormattedTime()Time as HH:MM:SS
int GetCurrentDay(), int GetTotalDaysPassed()Day counters
void SetDay(int day), void ResetDayCounter()Set or reset the day counter
float GetSunHeight()Sine of the sun's elevation: 1 overhead, 0 on the horizon, negative below it
bool IsSunUp()True while the sun height is above sunLightOnHeightThreshold
bool IsDayTime(), bool IsNightTime()Day is from dayStartTime to nightStartTime
float GetTimeOfDayFactor()A continuous 0 to 1 daylight factor from the sun height
float GetDayStartTime(), GetSunriseTime(), GetSunsetTime(), GetNightStartTime()The configured times
float GetCustomEventTime(string name)Time of an enabled custom event, or -1
bool IsCustomEventEnabled(string name)Whether that custom event is enabled
CustomEventTime[] GetAllCustomEventTimes()All custom event times
event Action OnDayCompletedEventFires when the clock passes midnight. The weather scheduler listens to it

Bu sayfaya bağlantı veren sayfalar

Hâlâ takıldınız mı?

Unity sürümünüzü, render pipeline bilginizi ve sorunun ekran görüntüsünü gönderin.

Destek alın