Skip to content

Commit b2bbcc0

Browse files
committed
Merge branch 'chore/visual-test-app-args' of github.com:decentraland/unity-explorer into test/visual-tests
2 parents 8e2fa5a + 5f57c3c commit b2bbcc0

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

Explorer/Assets/DCL/PluginSystem/Global/SkyboxPlugin.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public async UniTask InitializeAsync(SkyboxTimeSettings pluginSettings, Cancella
6767
if (settingsJson.DayCycleDurationInSeconds != null)
6868
skyboxSettings.FullDayCycleInSeconds = settingsJson.DayCycleDurationInSeconds.Value;
6969

70-
SetInitialTime(settingsJson, skyboxSettings);
70+
SetInitialTime(settingsJson, skyboxSettings, skyboxTimeEnabled);
7171

7272
skyboxRenderController = Object.Instantiate((await assetsProvisioner.ProvideMainAssetAsync(skyboxSettings.SkyboxRenderControllerPrefab, ct: ct)).Value);
7373

@@ -83,7 +83,8 @@ public async UniTask InitializeAsync(SkyboxTimeSettings pluginSettings, Cancella
8383
directionalLight,
8484
skyboxAnimation,
8585
skyboxSettings.TimeOfDayNormalized,
86-
lensFlareEnabled
86+
lensFlareEnabled,
87+
freezeTime: !skyboxTimeEnabled
8788
);
8889

8990
if (!skyboxTimeEnabled)
@@ -101,8 +102,21 @@ public async UniTask InitializeAsync(SkyboxTimeSettings pluginSettings, Cancella
101102

102103
return;
103104

104-
void SetInitialTime(SkyboxSettings jsonConfig, SkyboxSettingsAsset skyboxSettings)
105+
void SetInitialTime(SkyboxSettings jsonConfig, SkyboxSettingsAsset skyboxSettings, bool timeEnabled)
105106
{
107+
// When skybox time is disabled, pin the initial time to noon so it's independent of host
108+
// clock / PlayerPrefs / FF — the update system that would honor those isn't injected here.
109+
if (!timeEnabled)
110+
{
111+
const float NOON = 0.5f;
112+
skyboxSettings.TimeOfDayNormalized = NOON;
113+
skyboxSettings.TargetTimeOfDayNormalized = NOON;
114+
skyboxSettings.UIOverrideTimeOfDayNormalized = NOON;
115+
skyboxSettings.IsUIControlled = true;
116+
skyboxSettings.IsDayCycleEnabled = false;
117+
return;
118+
}
119+
106120
if (DCLPlayerPrefs.HasKey(DCLPrefKeys.SKYBOX_FIXED_TIME))
107121
{
108122
float fixedTime = DCLPlayerPrefs.GetFloat(DCLPrefKeys.SKYBOX_FIXED_TIME);

Explorer/Assets/DCL/SkyBox/SkyboxRenderController.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,16 @@ public class LensFlareTimeEntry
8585
[Header("Transition Settings")]
8686
[SerializeField] private float transitionDuration;
8787

88-
public void Initialize(Material skyboxMat, Light dirLight, AnimationClip skyboxAnimationClip, float initialTimeOfDay, bool lensFlareEnabled = true)
88+
public void Initialize(Material skyboxMat, Light dirLight, AnimationClip skyboxAnimationClip, float initialTimeOfDay, bool lensFlareEnabled = true, bool freezeTime = false)
8989
{
90+
// Pre-seed transition target so UpdateSkybox below short-circuits and skips the directional-light
91+
// coroutine, whose first sync tick would Lerp from float.MinValue and clamp the gradient samplers.
92+
if (freezeTime)
93+
{
94+
directionalLightTimeOfDay = initialTimeOfDay;
95+
targetTimeOfDay = initialTimeOfDay;
96+
}
97+
9098
if (skyboxMat)
9199
{
92100
#if UNITY_EDITOR

0 commit comments

Comments
 (0)