Files
Pal3.Unity/Assets/Scripts/Pal3.Game/Settings/MultisampleAntiAliasing.cs
Jiaqi (0x7c13) Liu b743505d54 Manage camera post-processing, anti-aliasing and menu glass
Give each game camera its own VolumeStack without mutating shared profiles, and restore inherited camera and effect state on disposal. Map the old PPv2 Bloom intensity through its exponential compositing coefficient; this does not establish visual equivalence across pipelines. Share saved and live MSAA handling with ResourceViewer, and make the main menu acrylic background whiter with less scene color showing through.

Restore pipeline settings even after partial initialization or service cleanup failure. Protect the persistent URP asset from ordinary Play Mode saves and restore the two runtime fields across Play exit and script reloads without reverting unrelated edits.
2026-11-12 00:12:19 +08:00

35 lines
998 B
C#

// See LICENSE in the project root.
namespace Pal3.Game.Settings
{
using System;
using UnityEngine.Rendering.Universal;
// Game and ResourceViewer apply the saved setting during their respective scenes.
public sealed class MultisampleAntiAliasing : IDisposable
{
private readonly UniversalRenderPipelineAsset _pipeline;
private readonly int _originalSampleCount;
private bool _disposed;
public MultisampleAntiAliasing(int samples)
{
_pipeline = UniversalRenderPipeline.asset;
_originalSampleCount = _pipeline.msaaSampleCount;
Apply(samples);
}
public void Apply(int samples)
{
_pipeline.msaaSampleCount = samples is 2 or 4 or 8 ? samples : 1;
}
public void Dispose()
{
if (_disposed) return;
_disposed = true;
if (_pipeline != null) _pipeline.msaaSampleCount = _originalSampleCount;
}
}
}