- ToonPostProcess.shader: 횃불 고딕 스타일 후처리 쉐이더 (Built-in RP) - ToonCameraEffect.cs: 카메라 자동 부착 후처리 스크립트 - 중복 UI 스크립트 제거 (MenuIntroController, ToggleCustom) - 씬, 프리팹, 애니메이션 등 전체 업데이트 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
176 lines
5.2 KiB
C#
176 lines
5.2 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.SceneManagement;
|
|
using TMPro;
|
|
|
|
public class LoadingController : MonoBehaviour
|
|
{
|
|
// 싱글톤
|
|
public static LoadingController Instance;
|
|
|
|
[Header("--- 로딩 캔버스 ---")]
|
|
public GameObject 로딩캔버스;
|
|
|
|
[Header("--- 마법진 ---")]
|
|
public RectTransform 마법진1;
|
|
public RectTransform 마법진2;
|
|
public float 마법진1속도 = 20f;
|
|
public float 마법진2속도 = 15f;
|
|
|
|
[Header("--- 힌트 ---")]
|
|
public TextMeshProUGUI 힌트텍스트;
|
|
[TextArea(2, 4)]
|
|
public string[] 힌트목록 = {
|
|
"⚔ 강한 적에게는 정면 돌파보다 측면 공격이 효과적입니다",
|
|
"🔮 마법은 마나가 부족할 때 사용하면 반동 피해를 입습니다",
|
|
"🛡 방어구의 내구도가 떨어지면 전투 전에 수리하세요",
|
|
"🌑 어둠 속에서는 횃불이 적의 시야를 차단해줍니다",
|
|
"⚗ 포션은 전투 중 즉시 사용할 수 있도록 단축키에 등록하세요"
|
|
};
|
|
public float 힌트변경시간 = 2.5f;
|
|
|
|
[Header("--- 진행바 ---")]
|
|
public Image 진행바;
|
|
public TextMeshProUGUI 퍼센트텍스트;
|
|
|
|
[Header("--- 페이드 ---")]
|
|
public Image 페이드오버레이;
|
|
public float 페이드시간 = 1.5f;
|
|
|
|
[Header("--- 씬 이름 ---")]
|
|
public string 게임씬이름 = "GameScene";
|
|
|
|
[Header("--- 메인메뉴 ---")]
|
|
public MenuIntroController 인트로컨트롤러;
|
|
|
|
private int 현재힌트 = 0;
|
|
private bool 로딩중 = false;
|
|
|
|
void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
public IEnumerator 로딩시작(string 씬이름 = "")
|
|
{
|
|
if (로딩중) yield break;
|
|
로딩중 = true;
|
|
|
|
if (씬이름 != "")
|
|
게임씬이름 = 씬이름;
|
|
|
|
if (인트로컨트롤러 != null)
|
|
yield return StartCoroutine(인트로컨트롤러.PlayOutro());
|
|
|
|
로딩캔버스.SetActive(true);
|
|
|
|
if (힌트텍스트 != null && 힌트목록.Length > 0)
|
|
힌트텍스트.text = 힌트목록[0];
|
|
|
|
yield return StartCoroutine(페이드인());
|
|
StartCoroutine(힌트교체());
|
|
StartCoroutine(마법진회전());
|
|
yield return StartCoroutine(진행바채우기());
|
|
}
|
|
|
|
IEnumerator 페이드인()
|
|
{
|
|
float time = 0f;
|
|
페이드오버레이.color = new Color(0, 0, 0, 1);
|
|
|
|
while (time < 페이드시간)
|
|
{
|
|
time += Time.deltaTime;
|
|
float alpha = Mathf.Lerp(1f, 0f, time / 페이드시간);
|
|
페이드오버레이.color = new Color(0, 0, 0, alpha);
|
|
yield return null;
|
|
}
|
|
|
|
페이드오버레이.color = new Color(0, 0, 0, 0);
|
|
}
|
|
|
|
IEnumerator 페이드아웃()
|
|
{
|
|
float time = 0f;
|
|
페이드오버레이.color = new Color(0, 0, 0, 0);
|
|
|
|
while (time < 페이드시간)
|
|
{
|
|
time += Time.deltaTime;
|
|
float alpha = Mathf.Lerp(0f, 1f, time / 페이드시간);
|
|
페이드오버레이.color = new Color(0, 0, 0, alpha);
|
|
yield return null;
|
|
}
|
|
|
|
페이드오버레이.color = new Color(0, 0, 0, 1);
|
|
}
|
|
|
|
IEnumerator 힌트교체()
|
|
{
|
|
while (로딩중)
|
|
{
|
|
yield return new WaitForSeconds(힌트변경시간);
|
|
현재힌트 = (현재힌트 + 1) % 힌트목록.Length;
|
|
|
|
if (힌트텍스트 != null)
|
|
힌트텍스트.text = 힌트목록[현재힌트];
|
|
}
|
|
}
|
|
|
|
IEnumerator 마법진회전()
|
|
{
|
|
while (로딩중)
|
|
{
|
|
if (마법진1 != null)
|
|
마법진1.Rotate(0, 0, 마법진1속도 * Time.deltaTime);
|
|
if (마법진2 != null)
|
|
마법진2.Rotate(0, 0, -마법진2속도 * Time.deltaTime);
|
|
yield return null;
|
|
}
|
|
}
|
|
|
|
IEnumerator 진행바채우기()
|
|
{
|
|
float progress = 0f;
|
|
|
|
AsyncOperation 로딩작업 =
|
|
SceneManager.LoadSceneAsync(게임씬이름);
|
|
로딩작업.allowSceneActivation = false;
|
|
|
|
while (progress < 1f)
|
|
{
|
|
float 목표 = Mathf.Clamp01(로딩작업.progress / 0.9f);
|
|
progress = Mathf.MoveTowards(progress, 목표, Time.deltaTime * 0.3f);
|
|
|
|
진행바.fillAmount = progress;
|
|
퍼센트텍스트.text = Mathf.RoundToInt(progress * 100f) + "%";
|
|
|
|
if (로딩작업.progress >= 0.9f)
|
|
{
|
|
progress = Mathf.MoveTowards(progress, 1f, Time.deltaTime * 0.2f);
|
|
진행바.fillAmount = progress;
|
|
퍼센트텍스트.text = Mathf.RoundToInt(progress * 100f) + "%";
|
|
if (progress >= 1f) break;
|
|
}
|
|
|
|
yield return null;
|
|
}
|
|
|
|
진행바.fillAmount = 1f;
|
|
퍼센트텍스트.text = "100%";
|
|
yield return new WaitForSeconds(0.5f);
|
|
|
|
로딩중 = false;
|
|
yield return StartCoroutine(페이드아웃());
|
|
로딩작업.allowSceneActivation = true;
|
|
}
|
|
} |