From d42d5cddf18d746835be7aff28a1d7f14f7aade4 Mon Sep 17 00:00:00 2001
From: drojf <1249449+drojf@users.noreply.github.com>
Date: Sun, 10 Dec 2023 13:29:35 +1100
Subject: [PATCH] Fix black backgrounds if bgs toggled after startup  - See
 #104

---
 Assets.Scripts.Core.Scene/Layer.cs | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/Assets.Scripts.Core.Scene/Layer.cs b/Assets.Scripts.Core.Scene/Layer.cs
index 5cee871e..03ef57e5 100644
--- a/Assets.Scripts.Core.Scene/Layer.cs
+++ b/Assets.Scripts.Core.Scene/Layer.cs
@@ -734,7 +734,18 @@ public void ReloadTexture()
 		{
 			if (PrimaryName == string.Empty)
 			{
-				HideLayer();
+				// PrimaryName is set to string.Empty when Layer's texture is released -
+				// therefore there is no texture to reload, so do nothing here.
+				//
+				// Note: Previously there was a HideLayer() call here, which caused problems
+				// with backgrounds if ReloadTexture() was called just after the game had started
+				// running, and DrawSceneWithMask() had not yet been called. It would cause
+				// backgrounds to display for one frame(?), then turn black.
+				//
+				// I think may be a special layer is activated on startup, but has no texture set,
+				// triggering this if statement.
+				//
+				// See https://github.com/07th-mod/higurashi-assembly/issues/104 for details
 			}
 			else
 			{