Persist painted maps and HUD layout across sessions

Add MeshPainter.Persistence.cs: auto-save the three canonical paint maps
(albedo, MSO, emission) as PNGs under persistentDataPath on quit/play-stop
and auto-load them as the backend seed on start, so painting survives
sessions. Reuses the existing ReadCanonical/SetupBackend seed round-trip;
no new color-space code.

Add PaintHud.Persistence.cs: auto-save draggable panel positions and the
widget-bound painter values to a small JSON layout file, restored on start
via the painter -> SyncFromPainter -> widgets path. Complete SyncFromPainter
to also cover the spray sliders.
This commit is contained in:
admin committed 2026-06-25 05:11:36 +02:00
1 parent 9dab4a742e
commit 95fa5cc22d
6 files changed
+404 -2

No files matched your search

+11 -1
View File
@@ -25,7 +25,7 @@ using UnityEngine.InputSystem.UI;
/// sliders, an HSV picker + intensity for emission, and brush size. Attach to an empty GameObject.
/// </summary>
[DisallowMultipleComponent]
public class PaintHud : MonoBehaviour
public partial class PaintHud : MonoBehaviour
{
[Tooltip("Mode manager driving visibility. Empty = found automatically.")]
public GameModeManager modeManager;
@@ -115,6 +115,9 @@ public class PaintHud : MonoBehaviour
// Re-sync every widget when the pipette adopts a sampled material (painter -> HUD).
if (painter) painter.Picked += SyncFromPainter;
// Restore the saved panel positions + widget values from the previous session.
RestoreHudState();
// Set initial visibility (the manager's first SwitchTo may have fired before this Start).
OnModeChanged(modeManager ? modeManager.ActiveMode : null);
}
@@ -122,6 +125,7 @@ public class PaintHud : MonoBehaviour
private void OnDestroy()
{
if (painter) painter.Picked -= SyncFromPainter;
SaveHudOnTeardown();
}
private void OnModeChanged(GameMode mode)
@@ -240,6 +244,12 @@ public class PaintHud : MonoBehaviour
SetSlider(panel, SliderOcclusionAlpha, painter.occlusionOpacity);
SetSlider(panel, SliderEmissionIntensity, painter.emissionIntensity);
SetSlider(panel, SliderBrushSize, painter.brushSize);
SetSlider(panel, SliderSprayDots, painter.sprayDots);
SetSlider(panel, SliderSprayDotSizeMin, painter.sprayDotSizeMin);
SetSlider(panel, SliderSprayDotSizeMax, painter.sprayDotSizeMax);
SetSlider(panel, SliderSprayDotAlphaMin, painter.sprayDotAlphaMin);
SetSlider(panel, SliderSprayDotAlphaMax, painter.sprayDotAlphaMax);
}
private static void SetToggle(Transform panel, string name, bool value)