From f586ef7a15f5e7bd800943c89a81c338f511bfbf Mon Sep 17 00:00:00 2001 From: MelekTaus Moribundus Date: Fri, 3 Jul 2026 14:52:22 +0200 Subject: [PATCH] Simplify HUD layout save path to a fixed PaintHud.json Drop the scene-derived hudSaveId/key mechanism and save the HUD layout to a single PaintHud.json under persistentDataPath. Co-Authored-By: Claude Opus 4.8 --- .../UI/PaintHud/PaintHud.Persistence.cs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/Assets/Scripts/Components/UI/PaintHud/PaintHud.Persistence.cs b/Assets/Scripts/Components/UI/PaintHud/PaintHud.Persistence.cs index 8c02d1c..2b17307 100644 --- a/Assets/Scripts/Components/UI/PaintHud/PaintHud.Persistence.cs +++ b/Assets/Scripts/Components/UI/PaintHud/PaintHud.Persistence.cs @@ -20,10 +20,6 @@ public partial class PaintHud "defaults every session.")] public bool persistHud = true; - [Tooltip("Save file identifier. Empty = derived from the HUD's own scene name. Set explicitly to keep " + - "the layout stable across scene renames or to share one layout between scenes.")] - public string hudSaveId = ""; - private const int HudFileVersion = 1; // Auto-save bookkeeping. Brush edits are debounced (sliders fire every frame while dragged): the due @@ -60,21 +56,11 @@ public partial class PaintHud private bool _hasDefaults; // non-camo defaults captured (first bind, before restore/carry) private bool _hasDefaultCamo; // camo defaults captured (first ready-gate, before any pending camo apply) - private static string HudSaveDir => Path.Combine(Application.persistentDataPath, "MeshPaint"); - private string HudSavePath() { - // Derive from the HUD's OWN scene (a stable persistent scene), not the active scene: the latter - // now changes across the additive lobby/map loads, so a key from it would split save and restore - // into different files and silently lose the saved layout. - string key = string.IsNullOrEmpty(hudSaveId) - ? SanitizeHudKey(gameObject.scene.name + "_hud") - : SanitizeHudKey(hudSaveId); - return Path.Combine(HudSaveDir, key + ".hudlayout"); + return Path.Combine(Application.persistentDataPath, "PaintHud.json"); } - private static string SanitizeHudKey(string s) => MeshPainter.SanitizeFileKey(s); - [Serializable] private class HudState { @@ -145,7 +131,7 @@ public partial class PaintHud state.hasHeightValues = _camoEverReady; } - Directory.CreateDirectory(HudSaveDir); + Directory.CreateDirectory(Application.persistentDataPath); File.WriteAllText(HudSavePath(), JsonUtility.ToJson(state, true)); // Refresh the on-disk baseline so the debounce does not immediately re-save unchanged values.