Project_WL/Assets/WL/Look/Character/WLCharacterLookSettings.cs

82 lines
3.9 KiB
C#

// ─────────────────────────────────────────────────────────────────────────────
// WLCharacterLookSettings.cs — 캐릭터 룩(배경과 같은 Toon) 되돌리기 스위치 (WL-814s)
//
// PD 지시 #814 · 발주서 WL-814s §1-5
//
// enabled_ = 0 → 원본 머티리얼 100 % (프리팹이 무엇을 들고 있든 런타임에 원본으로 되돌린다)
// mode 0 = 원본 · 1 = 셰이더만 · 2 = 셰이더+텍스처 축소 · 3 = 전부(+평탄화)
//
// 🔴 이 SO 는 「어떤 머티리얼을 쓸지」만 들고 있다. 머티리얼 파일 자체에는 아무 값도 쓰지 않는다.
// 🔴 originals 는 반드시 채워 둔다 — 프리팹이 새 머티리얼을 들고 있으므로 이 배열이
// 유일한 원본 참조다(잃어버리면 되돌리기가 깨진다).
// 🔴 Assets/WL/Look/Character/ 에 .asmdef 를 만들지 말 것.
// 🔴 Debug.LogError / Debug.LogException 을 쓰지 않는다(813z 규칙).
// ─────────────────────────────────────────────────────────────────────────────
using UnityEngine;
namespace WL.Look.Character
{
public class WLCharacterLookSettings : ScriptableObject
{
[Header("스위치")]
[Tooltip("0 이면 원본 머티리얼 100 % (이 기능 전체 off)")]
public int enabled_ = 1;
[Tooltip("0 = 원본 · 1 = 셰이더만 · 2 = 셰이더+텍스처 축소 · 3 = 전부(축소+평탄화)")]
public int mode = 1;
[Tooltip("1 이면 적용 내역을 로그로 남긴다")]
public int verboseLog = 0;
[Header("머티리얼 표 (같은 인덱스끼리 짝)")]
public Material[] originals; // 원본 (Toon/Toon · Unlit/Transparent)
public Material[] mode1; // Shader Graphs/Toon + 원본 텍스처
public Material[] mode2; // Shader Graphs/Toon + 축소 텍스처
public Material[] mode3; // Shader Graphs/Toon + 축소·평탄화 텍스처
// ───────────────────────────────────────── 싱글턴(Resources)
public const string ResourcePath = "WL/WLCharacterLookSettings";
static WLCharacterLookSettings s_inst;
static bool s_tried;
public static WLCharacterLookSettings Instance
{
get
{
if (s_inst == null && !s_tried)
{
s_tried = true;
s_inst = Resources.Load<WLCharacterLookSettings>(ResourcePath);
}
return s_inst;
}
}
/// <summary>프로브·에디터에서 SO 를 바꿔 끼웠을 때 다시 읽게 한다.</summary>
public static void Invalidate() { s_inst = null; s_tried = false; }
public static bool Enabled
{
get { var c = Instance; return c != null && c.enabled_ != 0; }
}
/// <summary>지금 적용해야 할 모드(스위치가 꺼져 있으면 0 = 원본).</summary>
public static int ActiveMode
{
get { var c = Instance; if (c == null || c.enabled_ == 0) return 0; return Mathf.Clamp(c.mode, 0, 3); }
}
/// <summary>모드에 해당하는 머티리얼 배열(없으면 originals).</summary>
public Material[] SetForMode(int m)
{
Material[] a = null;
if (m == 1) a = mode1;
else if (m == 2) a = mode2;
else if (m == 3) a = mode3;
if (a == null || originals == null || a.Length != originals.Length) return originals;
return a;
}
}
}