using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace TKS.OutGame
{
///
/// 씬 바꿈 페이드(PD 2026-11-16 「타이틀 화면은 별도의 씬으로 구성」) — 씬이 바뀌어도 남는 화면 덮개(오버레이 캔버스 · 씬 카메라와 무관)로
/// 페이드 아웃 → 씬 불러오기 → 검정 유지 → 페이드 인 → 스스로 사라짐. 이미 검정이면(FromBlack) 페이드 아웃 없이 바로 불러옴.
/// 시계 = LoadingScreen.Now(확인 캡처 때 게임 시간과 같음).
///
public class SceneSwitch : MonoBehaviour
{
public static SceneSwitch Current { get; private set; }
public Image Img { get; private set; }
public string Target { get; private set; }
/// 새 씬을 불러왔는가(페이드 인 시작 전 true).
public bool Loaded { get; private set; }
float fOut;
float fHold;
float fIn;
/// 지금 화면에서 페이드 아웃 → scene → 페이드 인.
public static SceneSwitch Go(string scene, float fadeOut, float hold, float fadeIn, Color color, int order)
{
return Make(scene, fadeOut, hold, fadeIn, color, order, 0f);
}
/// 이미 같은 색으로 덮인 화면(앞 페이드가 끝난 상태)에서 → scene → 페이드 인.
public static SceneSwitch FromBlack(string scene, float hold, float fadeIn, Color color, int order)
{
return Make(scene, 0f, hold, fadeIn, color, order, 1f);
}
static SceneSwitch Make(string scene, float fadeOut, float hold, float fadeIn, Color color, int order, float startAlpha)
{
if (Current != null) Destroy(Current.gameObject);
var go = new GameObject("SceneSwitch");
DontDestroyOnLoad(go);
var s = go.AddComponent();
Current = s;
var canvas = go.AddComponent