Pleebie Jeebies Company Logo

Pleebie Jeebies

Day, Night, and Light Controller (3D)

About

The Day, Night, and Light Controller asset provides a simple way to add and control day and night cycles in your 3D landscape scene. By default, this asset can also control lighting in the scene to turn off during the day and back on at night. This setting can be turned off by the use of a checkbox if you would like to control lighting through other means.

The main functions of this asset are:

Asset Files Hierarchy

All files are located under Assets/PleebieJeebies/

Asset File Hierarchy

Prefabs Folder

The Prefabs folder contains the DayNightAndLightController prefab and three spotlight prefabs used in the scene. The controller prefab can be dragged into any scene in your project to start using it.

The controller prefab also comes with its own directional light; you should only have one in your scene otherwise you may get undesired results.
If you already have a directional light in your scene with your desired settings, just copy over the light component properties to the directional light contained in the controller prefab, along with any other components on your directional light, and delete any other directional lights in the scene.

The three spotlight prefabs are spotlights pre-built with settings that allow for casting shadows at different angles.

Scenes Folder

The Scenes folder contains a demonstration (demo) scene that displays the day and night cycle and lighting that turns on and off depending on the time of day. Coloring is controlled by a preset. The Scripts Folder section will cover where to find these presets.

Scripts Folder

The Scripts folder contains two scripts and a folder: the LightManager script is the functionality of this asset and the LightPreset script is a Unity scriptable object to allow for easily creating color gradients used in the manager.

The LightPresets folder contains two presets, which are also used in the scene: one for the day and night cycle coloring, the other for spot light coloring. To change this coloring, see the Changing Coloring section.

Configuration

The configuration section covers the variables and modifiers used on the day, night, and light controller prefab.

You do not have to manually configure anything on the controller prefab as it functions by simply dragging it into any scene.

Configuration

Directional Light – Contains the directional light object you would like the controller prefab to use in the scene. By default, it is set to the directional light provided in the prefab.

Day Night Preset – Contains a LightPreset scriptable object set to change the scene coloring for the day and night cycle. You should explore this preset object and change the coloring to match your desired output. Read the Changing Coloring section on how to do this.

Lamp Preset – Contains a LightPreset scriptable object for turning on the lights during the night cycle.

Time Of Day – The current minute of the cycle the prefab is in. The range is between 0 and 1440 (24 x 60) equaling how many minutes are in a real day. 0 representing 0:00am or midnight and 1440 representing 11:59pm or the minute before midnight.

Sun Direction – Control where the directional light or ‘sun’ rises and sets. The value can be changed between 0 and 360 representing the full rotation of a circle, anything more than 360 continues the same rotation. The value you set is where the sun rises.
For example, if the value is 0, but you want the sun to rise on the opposite side of the scene from where it is currently, set it to 180. 90 will be a quarter way around the scene from 0, and 270 is three quarters around the scene from 0.

Time Multiplier – Sets the speed at which the Time Of Day is calculated. Leaving it at 1 means one minute is one real life second. Higher than 1 means time will go by quicker and lower than 1 means slower. For example, if the value is at 1, a full cycle takes 24 real minutes, or at 60, 24 real seconds, or at 1/60 ie. 0.016 repeating, 24 real hours.

Control Lights – Control all non-directional lights in the current scene to work according to the day and night cycle simulated. Toggle this off to make the prefab not control these lights. The Control Lights toggle does not stop the control of the directional light as that is the main ‘sun’ for the scene to simulate the cycle.

Changing Coloring

To change the color simulating the day and night cycle, select the SunlightPreset file located in PleebieJeebies/Scripts/LightPresets/

Use the color gradient boxes to change to a desired color palette.

Sunlight Preset

Ambient Color – Coloring of the render settings ambient lighting in the scene.

Directional Color – Set the amount of light or color given off by the directional light or ‘sun’.

Fog Color – Coloring of the render settings fog coloring in the scene.


To learn more about Unity lighting and rendering:
Unity Intro to Lighting and Rendering

If you are experiencing any issues, contact our support team at:
support@pleebiejeebies.com

Pleebie Jeebies Company Logo

Back to Top of Page