103 lines
5.1 KiB
C#
103 lines
5.1 KiB
C#
|
|
// PD 지시 #763 + #764 — 설정 에셋 생성 / WL_Start MapData 값 세팅 / 펫 플래그 토글
|
||
|
|
//
|
||
|
|
// 실행 (CLAUDE.md §1: using 금지 · 네임스페이스 풀어 쓰기)
|
||
|
|
// unity command run_script --file AgentScripts/WL764_Apply.cs --entry WL764_Apply.CreateSettings --timeout 120
|
||
|
|
// unity command run_script --file AgentScripts/WL764_Apply.cs --entry WL764_Apply.SetMapData --timeout 120
|
||
|
|
// unity command run_script --file AgentScripts/WL764_Apply.cs --entry WL764_Apply.PetOn / PetOff
|
||
|
|
// unity command run_script --file AgentScripts/WL764_Apply.cs --entry WL764_Apply.Show
|
||
|
|
//
|
||
|
|
// 이 스크립트는 **에셋에 값을 쓰는 유일한 경로**다(코드 상수 아님 · C45).
|
||
|
|
// 아래 상수는 "에셋에 써 넣을 초기값"이며 이후 조정은 인스펙터에서 한다.
|
||
|
|
|
||
|
|
public static class WL764_Apply
|
||
|
|
{
|
||
|
|
const string kSettingsDir = "Assets/WL/Settings/Resources/WL";
|
||
|
|
const string kSettingsAsset = "Assets/WL/Settings/Resources/WL/WLGameplaySettings.asset";
|
||
|
|
const string kTargetPrefab = "Assets/Res_Addr/Map/WL_Start.prefab";
|
||
|
|
|
||
|
|
// WL_Start MapData 초기값 (#764) — 실측으로 정한다
|
||
|
|
const bool kRequireReachable = true;
|
||
|
|
const float kSpawnSnapRadius = 2.0f; // 무작위 점을 NavMesh 로 끌어당길 최대 거리(m)
|
||
|
|
const int kSpawnTries = 50; // DSUtil 기존 기본값과 동일
|
||
|
|
const float kMobNavSnapRadius = 2.0f; // 넉백·끌어당김 후 NavMesh 복귀 반경(m)
|
||
|
|
|
||
|
|
public static string CreateSettings()
|
||
|
|
{
|
||
|
|
if (!UnityEditor.AssetDatabase.IsValidFolder("Assets/WL/Settings/Resources"))
|
||
|
|
UnityEditor.AssetDatabase.CreateFolder("Assets/WL/Settings", "Resources");
|
||
|
|
if (!UnityEditor.AssetDatabase.IsValidFolder(kSettingsDir))
|
||
|
|
UnityEditor.AssetDatabase.CreateFolder("Assets/WL/Settings/Resources", "WL");
|
||
|
|
|
||
|
|
var existing = UnityEditor.AssetDatabase.LoadAssetAtPath<WL.Settings.WLGameplaySettings>(kSettingsAsset);
|
||
|
|
if (existing != null)
|
||
|
|
return "이미 존재: " + kSettingsAsset + " spawnPlayerPet=" + existing.spawnPlayerPet;
|
||
|
|
|
||
|
|
var so = UnityEngine.ScriptableObject.CreateInstance<WL.Settings.WLGameplaySettings>();
|
||
|
|
so.spawnPlayerPet = false; // PD 지시 #763
|
||
|
|
UnityEditor.AssetDatabase.CreateAsset(so, kSettingsAsset);
|
||
|
|
UnityEditor.AssetDatabase.SaveAssets();
|
||
|
|
UnityEditor.AssetDatabase.Refresh();
|
||
|
|
WL.Settings.WLGameplaySettings.ClearCache();
|
||
|
|
return "생성 완료: " + kSettingsAsset + " spawnPlayerPet=false";
|
||
|
|
}
|
||
|
|
|
||
|
|
public static string PetOn() { return SetPet(true); }
|
||
|
|
public static string PetOff() { return SetPet(false); }
|
||
|
|
|
||
|
|
static string SetPet(bool v)
|
||
|
|
{
|
||
|
|
var so = UnityEditor.AssetDatabase.LoadAssetAtPath<WL.Settings.WLGameplaySettings>(kSettingsAsset);
|
||
|
|
if (so == null) return "[에러] 에셋 없음: " + kSettingsAsset;
|
||
|
|
so.spawnPlayerPet = v;
|
||
|
|
UnityEditor.EditorUtility.SetDirty(so);
|
||
|
|
UnityEditor.AssetDatabase.SaveAssets();
|
||
|
|
WL.Settings.WLGameplaySettings.ClearCache();
|
||
|
|
return "spawnPlayerPet = " + v;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static string SetMapData()
|
||
|
|
{
|
||
|
|
var root = UnityEditor.PrefabUtility.LoadPrefabContents(kTargetPrefab);
|
||
|
|
string r;
|
||
|
|
try
|
||
|
|
{
|
||
|
|
var md = root.GetComponent<MapData>();
|
||
|
|
if (md == null) { return "[에러] MapData 컴포넌트 없음"; }
|
||
|
|
md.spawnRequireReachableFromPlayer = kRequireReachable;
|
||
|
|
md.spawnSnapRadius = kSpawnSnapRadius;
|
||
|
|
md.spawnSampleTries = kSpawnTries;
|
||
|
|
md.mobNavSnapRadius = kMobNavSnapRadius;
|
||
|
|
UnityEditor.EditorUtility.SetDirty(md);
|
||
|
|
UnityEditor.PrefabUtility.SaveAsPrefabAsset(root, kTargetPrefab);
|
||
|
|
r = "WL_Start MapData: requireReachable=" + md.spawnRequireReachableFromPlayer
|
||
|
|
+ " snapRadius=" + md.spawnSnapRadius + " tries=" + md.spawnSampleTries
|
||
|
|
+ " mobNavSnap=" + md.mobNavSnapRadius;
|
||
|
|
}
|
||
|
|
finally { UnityEditor.PrefabUtility.UnloadPrefabContents(root); }
|
||
|
|
UnityEditor.AssetDatabase.SaveAssets();
|
||
|
|
UnityEditor.AssetDatabase.Refresh();
|
||
|
|
return r;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static string Show()
|
||
|
|
{
|
||
|
|
var sb = new System.Text.StringBuilder();
|
||
|
|
var so = UnityEditor.AssetDatabase.LoadAssetAtPath<WL.Settings.WLGameplaySettings>(kSettingsAsset);
|
||
|
|
sb.Append("설정에셋 = " + (so == null ? "없음" : ("spawnPlayerPet=" + so.spawnPlayerPet)));
|
||
|
|
|
||
|
|
var root = UnityEditor.PrefabUtility.LoadPrefabContents(kTargetPrefab);
|
||
|
|
try
|
||
|
|
{
|
||
|
|
var md = root.GetComponent<MapData>();
|
||
|
|
if (md == null) sb.Append(" | MapData 없음");
|
||
|
|
else sb.Append(" | WL_Start: requireReachable=" + md.spawnRequireReachableFromPlayer
|
||
|
|
+ " snapRadius=" + md.spawnSnapRadius + " tries=" + md.spawnSampleTries
|
||
|
|
+ " mobNavSnap=" + md.mobNavSnapRadius);
|
||
|
|
var mgrs = root.GetComponentsInChildren<MobControlMgr>(true);
|
||
|
|
sb.Append(" | 스포너 " + mgrs.Length + "개");
|
||
|
|
}
|
||
|
|
finally { UnityEditor.PrefabUtility.UnloadPrefabContents(root); }
|
||
|
|
return sb.ToString();
|
||
|
|
}
|
||
|
|
}
|