115 lines
5.2 KiB
C#
115 lines
5.2 KiB
C#
// WL771_Look.cs — PD 지시 #771 룩 보정 (PM 결정 ①·②)
|
|
// 포스트 벤더 톤화 : unity command run_script --file AgentScripts/WL771_Look.cs --entry WL771_Look.PostVendor --args '["Assets/WL/Settings/WL_Nature_Post.asset"]'
|
|
// 안개 end 변경 : ... --entry WL771_Look.Fog --args '["Assets/Res_Addr/Map/WL_Nature.prefab", 400.0]'
|
|
// 현재값 덤프 : ... --entry WL771_Look.Dump --args '["Assets/WL/Settings/WL_Nature_Post.asset","Assets/Res_Addr/Map/WL_Nature.prefab"]'
|
|
using System;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
#if UNITY_EDITOR
|
|
using UnityEditor;
|
|
#endif
|
|
|
|
public static class WL771_Look
|
|
{
|
|
#if UNITY_EDITOR
|
|
static string Fmt(VolumeParameter p) { return p == null ? "(null)" : p.GetType().GetProperty("value").GetValue(p) + (p.overrideState ? "" : " (no-override)"); }
|
|
|
|
public static object Dump(string profilePath, string prefabPath)
|
|
{
|
|
var sb = new StringBuilder();
|
|
var prof = AssetDatabase.LoadAssetAtPath<VolumeProfile>(profilePath);
|
|
sb.AppendLine("# " + profilePath);
|
|
if (prof == null) sb.AppendLine(" LOAD FAIL");
|
|
else foreach (var c in prof.components)
|
|
{
|
|
sb.AppendLine(" [" + c.GetType().Name + "] active=" + c.active);
|
|
foreach (var f in c.GetType().GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance))
|
|
if (typeof(VolumeParameter).IsAssignableFrom(f.FieldType))
|
|
sb.AppendLine(" " + f.Name + " = " + Fmt(f.GetValue(c) as VolumeParameter));
|
|
}
|
|
var root = PrefabUtility.LoadPrefabContents(prefabPath);
|
|
try
|
|
{
|
|
var md = root.GetComponentInChildren(System.Type.GetType("MapData, Assembly-CSharp"), true);
|
|
if (md == null) sb.AppendLine("# MapData 없음");
|
|
else
|
|
{
|
|
sb.AppendLine("# MapData (" + prefabPath + ")");
|
|
foreach (var f in md.GetType().GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance))
|
|
if (f.Name.ToLower().Contains("fog") || f.Name.ToLower().Contains("ambient") || f.Name.ToLower().Contains("sky"))
|
|
sb.AppendLine(" " + f.Name + " = " + f.GetValue(md));
|
|
}
|
|
}
|
|
finally { PrefabUtility.UnloadPrefabContents(root); }
|
|
return sb.ToString();
|
|
}
|
|
|
|
// PM 결정 ① — 벤더(LMHPOLY Demo_01) 톤으로 복귀
|
|
public static object PostVendor(string profilePath)
|
|
{
|
|
var prof = AssetDatabase.LoadAssetAtPath<VolumeProfile>(profilePath);
|
|
if (prof == null) return "profile load fail: " + profilePath;
|
|
var sb = new StringBuilder();
|
|
foreach (var c in prof.components)
|
|
{
|
|
var n = c.GetType().Name;
|
|
if (n == "ColorAdjustments")
|
|
{
|
|
Set(c, "postExposure", 0f, sb); Set(c, "contrast", 0f, sb);
|
|
}
|
|
else if (n == "Tonemapping")
|
|
{
|
|
var f = c.GetType().GetField("mode");
|
|
if (f != null) { var p = f.GetValue(c) as VolumeParameter; var pi = p.GetType().GetProperty("value"); sb.AppendLine(" Tonemapping.mode " + pi.GetValue(p) + " -> None"); pi.SetValue(p, 0); p.overrideState = true; }
|
|
}
|
|
else if (n == "WhiteBalance")
|
|
{
|
|
Set(c, "temperature", 0f, sb); Set(c, "tint", 0f, sb);
|
|
}
|
|
else if (n == "Bloom")
|
|
{
|
|
Set(c, "threshold", 0.5f, sb); Set(c, "intensity", 0.5f, sb);
|
|
}
|
|
}
|
|
EditorUtility.SetDirty(prof);
|
|
AssetDatabase.SaveAssets();
|
|
return sb.ToString();
|
|
}
|
|
|
|
static void Set(VolumeComponent c, string field, float v, StringBuilder sb)
|
|
{
|
|
var f = c.GetType().GetField(field);
|
|
if (f == null) { sb.AppendLine(" " + c.GetType().Name + "." + field + " = FIELD NOT FOUND"); return; }
|
|
var p = f.GetValue(c) as VolumeParameter;
|
|
if (p == null) { sb.AppendLine(" " + c.GetType().Name + "." + field + " = NOT A PARAM"); return; }
|
|
var pi = p.GetType().GetProperty("value");
|
|
sb.AppendLine(" " + c.GetType().Name + "." + field + " " + pi.GetValue(p) + " -> " + v);
|
|
pi.SetValue(p, v);
|
|
p.overrideState = true;
|
|
}
|
|
|
|
// PM 결정 ② — 안개 end
|
|
public static object Fog(string prefabPath, float fogEnd)
|
|
{
|
|
var sb = new StringBuilder();
|
|
var root = PrefabUtility.LoadPrefabContents(prefabPath);
|
|
try
|
|
{
|
|
var md = root.GetComponentInChildren(System.Type.GetType("MapData, Assembly-CSharp"), true);
|
|
if (md == null) { return "MapData 없음: " + prefabPath; }
|
|
var f = md.GetType().GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)
|
|
.FirstOrDefault(x => x.Name.ToLower().Contains("fogend"));
|
|
if (f == null) return "fogEnd 필드 없음";
|
|
sb.AppendLine(" " + f.Name + " " + f.GetValue(md) + " -> " + fogEnd);
|
|
f.SetValue(md, fogEnd);
|
|
PrefabUtility.SaveAsPrefabAsset(root, prefabPath);
|
|
}
|
|
finally { PrefabUtility.UnloadPrefabContents(root); }
|
|
AssetDatabase.SaveAssets();
|
|
return sb.ToString();
|
|
}
|
|
#endif
|
|
}
|