대화 시작시 기본회전 막기 옵션 추가

This commit is contained in:
2026-07-23 15:06:05 +09:00
parent de5fe5b85a
commit c3a8d1ce2e
8 changed files with 134 additions and 23 deletions

View File

@@ -22,6 +22,11 @@ public class LocalManager : MonoBehaviour,ISceneInitializable
// 이 씬 전용 스카이박스 (비우면 SceneLoadManager의 기본 스카이박스 사용)
[SerializeField] private Material _sceneSkybox;
// FadeToGrayscale 직전의 원래 볼륨 상태 — FadeToColor로 되돌릴 때 복원용
private VolumeProfile _preGrayscaleProfile;
private float _preGrayscaleWeight;
private bool _grayscaleActive;
public void NextScene(int delay)
{
_ = Util.RunDelayed((float)delay,()=>SceneLoadManager.Instance.RequestSceneChange(_nextSceneName));
@@ -72,7 +77,8 @@ private static void PauseAllAnimations()
// 씬의 글로벌 볼륨 프로파일을 흑백으로 교체하고 weight를 0 → 1로 페이드 (완전 흑백)
// 기존 프로파일(그레인/모션블러 포함)이 통째로 빠지므로 정지 화면에서 지글거림도 없다
private async Awaitable FadeToGrayscale(float duration)
// 같은 씬 어디서든 참조로 호출 가능. 되돌리려면 FadeToColor 사용.
public async Awaitable FadeToGrayscale(float duration)
{
if (_grayscaleProfile == null || _globalVolume == null)
{
@@ -80,6 +86,14 @@ private async Awaitable FadeToGrayscale(float duration)
return;
}
// 원래 볼륨 상태를 기억해 둔다 (FadeToColor 복원용). 이미 흑백이면 덮어쓰지 않는다.
if (!_grayscaleActive)
{
_preGrayscaleProfile = _globalVolume.sharedProfile;
_preGrayscaleWeight = _globalVolume.weight;
_grayscaleActive = true;
}
// sharedProfile로 물려야 에셋이 복제·수정되지 않는다 (페이드는 weight로만)
// 씬 오브젝트의 프로퍼티 변경이라 플레이 종료 시 원래대로 돌아온다
_globalVolume.sharedProfile = _grayscaleProfile;
@@ -89,14 +103,45 @@ private async Awaitable FadeToGrayscale(float duration)
foreach (var cam in FindObjectsByType<Camera>())
cam.GetUniversalAdditionalCameraData().renderPostProcessing = true;
await FadeVolumeWeight(0f, 1f, duration);
}
// 흑백 → 원래 컬러로 되돌린다. weight를 0으로 뺀 뒤, FadeToGrayscale가 기억해둔 원래 프로파일/weight로 복원.
// 흑백 상태가 아니면 아무것도 하지 않는다. 같은 씬 어디서든 참조로 호출 가능.
public async Awaitable FadeToColor(float duration)
{
if (_globalVolume == null || !_grayscaleActive)
return;
await FadeVolumeWeight(_globalVolume.weight, 0f, duration);
_globalVolume.sharedProfile = _preGrayscaleProfile;
_globalVolume.weight = _preGrayscaleWeight;
_grayscaleActive = false;
}
// 인스펙터 UnityEvent에서 호출용 void 래퍼.
// (async 메서드는 반환형이 void가 아니라 UnityEvent 드롭다운에 안 뜬다 — 여기서 fire-and-forget으로 감싼다)
public void FadeToGrayscaleEvent(float duration) => _ = FadeToGrayscale(duration);
public void FadeToColorEvent(float duration) => _ = FadeToColor(duration);
// 글로벌 볼륨 weight를 from → to로 duration 동안 페이드 (duration ≤ 0이면 즉시 to)
private async Awaitable FadeVolumeWeight(float from, float to, float duration)
{
if (duration <= 0f)
{
_globalVolume.weight = to;
return;
}
float timer = 0f;
while (timer < duration)
{
timer += Time.deltaTime;
_globalVolume.weight = Mathf.Clamp01(timer / duration);
_globalVolume.weight = Mathf.Lerp(from, to, Mathf.Clamp01(timer / duration));
await Awaitable.NextFrameAsync(destroyCancellationToken);
}
_globalVolume.weight = 1f;
_globalVolume.weight = to;
}
// 씬 로드 시 이 씬 전용 스카이박스를 적용