Project_WL/AgentScripts/WL_GameViewSize.cs

135 lines
5.9 KiB
C#
Raw Normal View History

WL 리뉴얼 세션 2026-09-06~07 (#760~#800) — 전투·배경·UI·타격감 (조직 PD 로그 #746~#800 · 대화로그 §14~§24) - 전투: Knight@Attack1~3_S 3콤보(4 컨트롤러·클래스별 서브클립) · 타겟팅 4규칙(정면 우선·재타겟·즉시 공격·어그로 금지 · WLTargetingSettings) · 대쉬 후 공격(Stander@Chase_Start · DashDriver · 5 m · 사정거리+0.8 · 근거리 적 우선) · 공격 이동 FrameTable(발 접지 실측 표 · AttackRootMotion) · 충돌 반경/투사체 0.3 배(WLCollisionTuning) · 무적(임시)·펫 금지(WLGameplaySettings) - 검기: NamuFX Slash_B 배리언트 Effect_WLSwingArc 원 피팅 정합 배치 + 캘리브레이션(SlashArcMeasure · SlashTrailSettings) · 찌르기 Effect_WLStab 대기 · 램프 리본(BladeTrail · WL_BladeRibbon.shader · T_WL_BladeRibbonRamp) 보존(drawRibbon 0) - 타격감: Assets/WL/Feel(WLHitFeel · 히트스톱 0.03 · 셰이크 0.10 m · 몹 펀치 1.12 · Actor.Get_Damage 훅 1줄 · 원본 RealCamera 셰이크 결함 대체) - 배경/맵: LMHPOLY Demo_01~10 → WL_Nature01~10(프리팹·씬·NavMesh·스포너·BattleMapConfig) · 물(ToonWaterU) · 포스트 블룸 0.9/0.3 · 잔디(BruteForce·드레싱) 제거 · 마젠타 머티리얼 URP 변환 - UI: 세로 HUD(WL_HUD · 하단 5메뉴 폭 전체 · 채팅/전투 패드 숨김 · WLIngameUiOverride) · Title/TitleInfo 1080×1920 Expand + 배경 높이 fit(WLBackgroundFit) · 로딩 SortOrder_5(WLRawImageAspectSync · 초점표 8장) · Loading1~8 ASTC 6×6 - 도구: AgentScripts/*(LightProbe · WL_MapSwitch · WL760~WL800 프로브/집행/검증 · 상단 사용법 주석) · 에디터 락 프로토콜 파일(staging) - 제외(별도 커밋 예정): Assets/LMHPOLY(703 MB) · Assets/Feel(422 MB) · Assets/Shinabro(300 MB) — 에셋 스토어/구 WL 팩 원본 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-06 23:24:25 +00:00
// WL_GameViewSize.cs — 게임뷰 해상도 전환 재사용 도구 (에디트 모드 · 프로젝트 에셋 미수정)
//
// 사용법:
// unity command run_script --file AgentScripts/WL_GameViewSize.cs --entry WL_GameViewSize.Set --args '[1080,1920]'
// unity command run_script --file AgentScripts/WL_GameViewSize.cs --entry WL_GameViewSize.Current
// unity command run_script --file AgentScripts/WL_GameViewSize.cs --entry WL_GameViewSize.List
//
// 왜 리플렉션인가: UnityEditor.GameViewSizes / GameViewSize / GameView 는 전부 internal 이라
// 공개 API 가 없다. 해상도별 UI 실측(CanvasScaler scaleFactor 는 Screen 크기에 의존)에는
// 게임뷰 해상도를 실제로 바꾸는 것 외에 방법이 없다.
//
// 주의: 게임뷰 크기는 에디터 상태이지 프로젝트 에셋이 아니다. 이 스크립트는 Assets 를 수정하지 않는다.
// 같은 (w,h) 로 다시 호출하면 커스텀 사이즈를 중복 생성하지 않고 기존 항목을 재사용한다.
using System;
using System.Linq;
using System.Reflection;
using System.Text;
using UnityEditor;
using UnityEngine;
public static class WL_GameViewSize
{
const string Tag = "WL"; // 이 도구가 만든 커스텀 사이즈 라벨 접두어
static Type T(string n) => typeof(Editor).Assembly.GetType(n);
static object SizesInstance()
{
var tSizes = T("UnityEditor.GameViewSizes");
var tSingle = typeof(ScriptableSingleton<>).Assembly
.GetType("UnityEditor.ScriptableSingleton`1").MakeGenericType(tSizes);
return tSingle.GetProperty("instance", BindingFlags.Public | BindingFlags.Static).GetValue(null);
}
static object CurrentGroup()
{
var inst = SizesInstance();
var tSizes = T("UnityEditor.GameViewSizes");
var groupType = tSizes.GetProperty("currentGroupType", BindingFlags.Public | BindingFlags.Instance).GetValue(inst);
return tSizes.GetMethod("GetGroup", BindingFlags.Public | BindingFlags.Instance).Invoke(inst, new[] { groupType });
}
static int FindIndex(int w, int h)
{
var group = CurrentGroup();
var tGroup = group.GetType();
int total = (int)tGroup.GetMethod("GetTotalCount", BindingFlags.Public | BindingFlags.Instance).Invoke(group, null);
var getSize = tGroup.GetMethod("GetGameViewSize", BindingFlags.Public | BindingFlags.Instance);
for (int i = 0; i < total; i++)
{
var s = getSize.Invoke(group, new object[] { i });
var st = s.GetType();
int sw = (int)st.GetProperty("width").GetValue(s);
int sh = (int)st.GetProperty("height").GetValue(s);
var kind = st.GetProperty("sizeType").GetValue(s).ToString();
if (sw == w && sh == h && kind == "FixedResolution") return i;
}
return -1;
}
static int EnsureSize(int w, int h)
{
int idx = FindIndex(w, h);
if (idx >= 0) return idx;
var tSize = T("UnityEditor.GameViewSize");
var tSizeType = T("UnityEditor.GameViewSizeType");
var ctor = tSize.GetConstructor(new[] { tSizeType, typeof(int), typeof(int), typeof(string) });
var fixedRes = Enum.Parse(tSizeType, "FixedResolution");
var size = ctor.Invoke(new[] { fixedRes, (object)w, h, Tag + " " + w + "x" + h });
var group = CurrentGroup();
group.GetType().GetMethod("AddCustomSize", BindingFlags.Public | BindingFlags.Instance)
.Invoke(group, new[] { size });
SizesInstance().GetType().GetMethod("SaveToHDD", BindingFlags.Public | BindingFlags.Instance)
?.Invoke(SizesInstance(), null);
return FindIndex(w, h);
}
static EditorWindow GameViewWindow()
{
var tGV = T("UnityEditor.GameView");
var wins = Resources.FindObjectsOfTypeAll(tGV);
if (wins != null && wins.Length > 0) return (EditorWindow)wins[0];
return EditorWindow.GetWindow(tGV, false, "Game", false);
}
/// 게임뷰를 지정 해상도(FixedResolution)로 전환하고 실제 Screen 크기를 돌려준다.
public static object Set(int w, int h)
{
int idx = EnsureSize(w, h);
if (idx < 0) return "ABORT: 사이즈 등록 실패 " + w + "x" + h;
var gv = GameViewWindow();
var tGV = gv.GetType();
var prop = tGV.GetProperty("selectedSizeIndex", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (prop != null) prop.SetValue(gv, idx);
else
{
var cb = tGV.GetMethod("SizeSelectionCallback", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (cb == null) return "ABORT: selectedSizeIndex / SizeSelectionCallback 둘 다 없음";
cb.Invoke(gv, new object[] { idx, null });
}
gv.Repaint();
// 캔버스 레이아웃을 새 해상도로 즉시 갱신 (실측 전 필수)
Canvas.ForceUpdateCanvases();
return "OK idx=" + idx + " 요청=" + w + "x" + h + " Screen=" + Screen.width + "x" + Screen.height;
}
public static object Current()
{
return "Screen=" + Screen.width + "x" + Screen.height;
}
public static object List()
{
var group = CurrentGroup();
var tGroup = group.GetType();
int total = (int)tGroup.GetMethod("GetTotalCount").Invoke(group, null);
var getSize = tGroup.GetMethod("GetGameViewSize");
var sb = new StringBuilder();
for (int i = 0; i < total; i++)
{
var s = getSize.Invoke(group, new object[] { i });
var st = s.GetType();
sb.AppendLine(i + ": " + st.GetProperty("sizeType").GetValue(s) + " "
+ st.GetProperty("width").GetValue(s) + "x" + st.GetProperty("height").GetValue(s)
+ " \"" + st.GetProperty("baseText").GetValue(s) + "\"");
}
return sb.ToString();
}
}