Skip to content

Commit

Permalink
Use different loading fade colors based on time of day
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Aug 4, 2023
1 parent 1a6bea5 commit c8aea63
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions MainGameVR/Features/VRFade.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections;
using ActionGame;
using UnityEngine;
using Valve.VR;
using VRGIN.Core;
Expand All @@ -16,7 +17,6 @@ internal class VRFade : ProtectedBehaviour
/// </summary>
private CanvasGroup _vanillaFade;

private readonly Color _fadeColor = Color.white;
private readonly float _gridFadeTime = 1;
private readonly float _fadeAlphaThresholdHigh = 0.9999f;
private readonly float _fadeAlphaThresholdLow = 0.0001f;
Expand Down Expand Up @@ -53,7 +53,7 @@ private IEnumerator DeepFadeCo()
_isFading = true;

// Make the world outside of the game the same color as the loading screen instead of the headset default skybox
SetCompositorSkyboxOverride(_fadeColor);
SetCompositorSkyboxOverride(GetFadeColor());

var compositor = OpenVR.Compositor;
if (compositor != null)
Expand Down Expand Up @@ -106,6 +106,33 @@ private IEnumerator DeepFadeCo()
_isFading = false;
}

private static Color GetFadeColor()
{
try
{
var cycle = FindObjectOfType<Cycle>();
switch (cycle?.nowType)
{
default:
case Cycle.Type.WakeUp:
case Cycle.Type.Morning:
case Cycle.Type.Daytime:
return new Color(0.44f, 0.78f, 1f);
case Cycle.Type.Evening:
return new Color(0.85f, 0.50f, 0.37f);
case Cycle.Type.Night:
case Cycle.Type.GotoMyHouse:
case Cycle.Type.MyHouse:
return new Color(0.12f, 0.2f, 0.5f);
}
}
catch (Exception e)
{
Console.WriteLine(e);
return Color.white;
}
}

private static void SetCompositorSkyboxOverride(Color fadeColor)
{
var tex = new Texture2D(1, 1);
Expand Down

0 comments on commit c8aea63

Please sign in to comment.