Project_WL/AgentScripts/WL_20261015_Setup.cs

84 lines
5.7 KiB
C#
Raw Permalink Normal View History

// ─────────────────────────────────────────────────────────────────────────────
// WL_20261015_Setup.cs — 2026-10-15 PD 지시 4건의 설정 에셋 값 넣기(에디터 · 1회성 · 다시 돌려도 같은 결과)
// ① 섬 무적 몬스터 1기(WLIslandMobSettings.hitTestDummy …)
// ② 상인 설치 = 밀짚모자 캐릭터(WLIslandSettings.flowSteps[상인].standIn…)
// ③ 하늘 = FS017 위 반구 + 전 하늘 바닥색 아래 반구(WL_Sky_FS017_Day.mat → WLIslandLookSettings.skybox)
// ④ 해변 걷기(WLIslandLookSettings.beachWalk…)
// 실행 = unity command run_script --file AgentScripts/WL_20261015_Setup.cs --entry WL_20261015_Setup.Run --args "[0.1407, 0.1231, 0.1113]"
// 인자 = 하늘 아래 반구 색(선형 · 실측 = 전 하늘 Default-Skybox 를 물 밑으로 본 색)
// ─────────────────────────────────────────────────────────────────────────────
using UnityEditor;
using UnityEngine;
public static class WL_20261015_Setup
{
public static string Run(float gr, float gg, float gb)
{
var sb = new System.Text.StringBuilder();
// ③ 하늘 재질
const string skyPath = "Assets/WL/Look/Sky/WL_Sky_FS017_Day.mat";
var src = AssetDatabase.LoadAssetAtPath<Material>("Assets/Fantasy Skybox FREE/Panoramics/FS017/FS017_Day.mat");
var sh = Shader.Find("WL/Skybox/Panoramic Ground");
if (src == null || sh == null) return "하늘 원본/셰이더 없음 src=" + (src != null) + " shader=" + (sh != null);
if (ShaderUtil.ShaderHasError(sh)) return "셰이더 오류 — WL/Skybox/Panoramic Ground";
var sky = AssetDatabase.LoadAssetAtPath<Material>(skyPath);
if (sky == null) { sky = new Material(sh); AssetDatabase.CreateAsset(sky, skyPath); }
sky.shader = sh;
sky.SetTexture("_MainTex", src.GetTexture("_MainTex"));
sky.SetColor("_Tint", src.GetColor("_Tint"));
sky.SetFloat("_Exposure", src.GetFloat("_Exposure"));
sky.SetFloat("_Rotation", src.GetFloat("_Rotation"));
// 🔴 [HDR] 색 속성은 선형 변환 없이 그대로 셰이더에 간다(실측: .gamma 로 넣은 0.4114 가 그대로 출력) → 선형 실측값을 그대로 넣는다
sky.SetColor("_GroundColor", new Color(gr, gg, gb, 1f));
sky.SetFloat("_GroundBlend", 0.05f);
EditorUtility.SetDirty(sky);
sb.AppendLine("하늘 재질 " + skyPath + " · 아래 반구 선형 (" + gr + ", " + gg + ", " + gb + ")");
// ③④ 섬 룩 설정
var look = AssetDatabase.LoadAssetAtPath<ScriptableObject>("Assets/WL/Look/Farm/Resources/WL/WLIslandLookSettings.asset");
var so = new SerializedObject(look);
so.FindProperty("skybox").objectReferenceValue = sky;
so.FindProperty("beachWalkEnabled").intValue = 1;
so.FindProperty("beachWalkAboveWater").floatValue = 0.15f;
so.FindProperty("beachWalkCell").floatValue = 0.25f;
so.FindProperty("beachWalkNavSlope").floatValue = 45f;
so.FindProperty("beachWalkNavRadius").floatValue = 0.3f;
so.ApplyModifiedPropertiesWithoutUndo(); EditorUtility.SetDirty(look);
sb.AppendLine("WLIslandLookSettings — skybox=" + sky.name + " · beachWalk 1 / 0.15 / 0.25 · 섬 내비메시 경사 45° · 반지름 0.3");
// ② 상인 단계
var isl = AssetDatabase.LoadAssetAtPath<ScriptableObject>("Assets/WL/Island/Resources/WL/WLIslandSettings.asset");
var so2 = new SerializedObject(isl);
var steps = so2.FindProperty("flowSteps");
int merchant = -1;
for (int i = 0; i < steps.arraySize; i++)
{
var e = steps.GetArrayElementAtIndex(i);
if (e.FindPropertyRelative("extraSkipIfComponent").stringValue == "Merchant" || e.FindPropertyRelative("prefabPath").stringValue.EndsWith("Stall01.prefab")) { merchant = i; break; }
}
if (merchant < 0) return sb + "상인 단계 못 찾음";
var m = steps.GetArrayElementAtIndex(merchant);
m.FindPropertyRelative("standInPrefabPath").stringValue = "Assets/WL/Island/NPC/WL_Merchant_Nolant_Yellow.prefab";
m.FindPropertyRelative("standInAttachComponent").stringValue = "Merchant";
m.FindPropertyRelative("standInLocalPosition").vector3Value = Vector3.zero;
m.FindPropertyRelative("standInHeight").floatValue = 1.3f;
m.FindPropertyRelative("standInInfoRadius").floatValue = 1.4f;
m.FindPropertyRelative("standInBlockRadius").floatValue = 0.4f;
so2.ApplyModifiedPropertiesWithoutUndo(); EditorUtility.SetDirty(isl);
sb.AppendLine("WLIslandSettings.flowSteps[" + merchant + "] 「" + m.FindPropertyRelative("label").stringValue + "」 standIn = WL_Merchant_Nolant_Yellow · 키 1.3 · 정보창 1.4 · 막힘 0.4");
// ① 무적 몬스터
var mob = AssetDatabase.LoadAssetAtPath<ScriptableObject>("Assets/WL/IslandMob/Resources/WL/WLIslandMobSettings.asset");
var so3 = new SerializedObject(mob);
so3.FindProperty("hitTestDummy").intValue = 1;
so3.FindProperty("hitTestDummyMobId").intValue = 101;
so3.FindProperty("hitTestDummyOffset").vector3Value = new Vector3(2f, 0f, -1.5f);
so3.ApplyModifiedPropertiesWithoutUndo(); EditorUtility.SetDirty(mob);
sb.AppendLine("WLIslandMobSettings — hitTestDummy 1 · mobId 101 · offset (2,0,-1.5) · zonesEnabled=" + so3.FindProperty("zonesEnabled").intValue);
AssetDatabase.SaveAssets();
return sb.ToString();
}
}