69 lines
3.8 KiB
C#
69 lines
3.8 KiB
C#
|
|
// WL-816a 추가 — 물(SimpleWater)도 데모 물 색으로 맞춘다.
|
||
|
|
// 데모 Water.mat 실측: _Tint(깊은 물) = (0.13333, 0.51765, 0.74510) · _Color(얕은 물) = (0.29804, 0.80000, 1.0)
|
||
|
|
// FarmingIsland SimpleWater 원본은 Color_A271762B(깊음) = (0, 0.31609, 0.90566) · Color_E0824245(얕음) = (0.17453, 0.59879, 1)
|
||
|
|
// 🔴 원본 .mat 은 수정하지 않는다 — 복사본을 만들어 씬에서 교체.
|
||
|
|
public static class WL816a_Water
|
||
|
|
{
|
||
|
|
const string DstScene = "Assets/WL/Look/Farm/Scenes/WL_FarmLook.unity";
|
||
|
|
const string SrcMat = "Assets/FarmingIsland/Materials/Environments/SimpleWater.mat";
|
||
|
|
const string NewMat = "Assets/WL/Look/Farm/Materials/Farm_SimpleWater_Demo.mat";
|
||
|
|
|
||
|
|
public static void Run()
|
||
|
|
{
|
||
|
|
var sb = new System.Text.StringBuilder();
|
||
|
|
var src = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEngine.Material>(SrcMat);
|
||
|
|
if (src == null) { UnityEngine.Debug.Log("[WL816a Water] 원본 없음"); return; }
|
||
|
|
|
||
|
|
var m = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEngine.Material>(NewMat);
|
||
|
|
if (m == null)
|
||
|
|
{
|
||
|
|
if (!UnityEditor.AssetDatabase.CopyAsset(SrcMat, NewMat)) { UnityEngine.Debug.Log("[WL816a Water] 복사 실패"); return; }
|
||
|
|
UnityEditor.AssetDatabase.Refresh();
|
||
|
|
m = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEngine.Material>(NewMat);
|
||
|
|
}
|
||
|
|
if (m == null) { UnityEngine.Debug.Log("[WL816a Water] 복사본 로드 실패"); return; }
|
||
|
|
|
||
|
|
var deepOld = m.GetColor("Color_A271762B");
|
||
|
|
var shallowOld = m.GetColor("Color_E0824245");
|
||
|
|
m.SetColor("Color_A271762B", new UnityEngine.Color(0.13333334f, 0.5176471f, 0.74509805f, deepOld.a));
|
||
|
|
m.SetColor("Color_E0824245", new UnityEngine.Color(0.2980392f, 0.8000001f, 1f, shallowOld.a));
|
||
|
|
UnityEditor.EditorUtility.SetDirty(m);
|
||
|
|
sb.AppendLine("물 복사본 " + NewMat);
|
||
|
|
sb.AppendLine(" 깊은물 " + deepOld + " → " + m.GetColor("Color_A271762B"));
|
||
|
|
sb.AppendLine(" 얕은물 " + shallowOld + " → " + m.GetColor("Color_E0824245"));
|
||
|
|
|
||
|
|
var scene = UnityEditor.SceneManagement.EditorSceneManager.OpenScene(
|
||
|
|
DstScene, UnityEditor.SceneManagement.OpenSceneMode.Single);
|
||
|
|
var comp = UnityEngine.Object.FindFirstObjectByType<WL.Look.Farm.WLFarmLook>(UnityEngine.FindObjectsInactive.Include);
|
||
|
|
if (comp == null) { UnityEngine.Debug.Log("[WL816a Water] WLFarmLook 없음"); return; }
|
||
|
|
|
||
|
|
var rends = UnityEngine.Object.FindObjectsByType<UnityEngine.Renderer>(
|
||
|
|
UnityEngine.FindObjectsInactive.Include, UnityEngine.FindObjectsSortMode.None);
|
||
|
|
var list = new System.Collections.Generic.List<WL.Look.Farm.WLFarmLook.Entry>(comp.entries);
|
||
|
|
int n = 0;
|
||
|
|
for (int i = 0; i < rends.Length; i++)
|
||
|
|
{
|
||
|
|
var r = rends[i];
|
||
|
|
if (r == null || r is UnityEngine.ParticleSystemRenderer) continue;
|
||
|
|
var ms = r.sharedMaterials;
|
||
|
|
bool hit = false;
|
||
|
|
for (int s = 0; s < ms.Length; s++) if (ms[s] == src) hit = true;
|
||
|
|
if (!hit) continue;
|
||
|
|
var nw = (UnityEngine.Material[])ms.Clone();
|
||
|
|
for (int s = 0; s < nw.Length; s++) if (nw[s] == src) nw[s] = m;
|
||
|
|
list.Add(new WL.Look.Farm.WLFarmLook.Entry
|
||
|
|
{ target = r, original = ms, toonTex = nw, toonFlat = nw });
|
||
|
|
r.sharedMaterials = nw;
|
||
|
|
UnityEditor.EditorUtility.SetDirty(r);
|
||
|
|
n++;
|
||
|
|
}
|
||
|
|
comp.entries = list.ToArray();
|
||
|
|
UnityEditor.EditorUtility.SetDirty(comp);
|
||
|
|
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(scene);
|
||
|
|
UnityEditor.SceneManagement.EditorSceneManager.SaveScene(scene);
|
||
|
|
UnityEditor.AssetDatabase.SaveAssets();
|
||
|
|
sb.AppendLine("물 렌더러 교체 " + n + " · entries " + comp.entries.Length);
|
||
|
|
UnityEngine.Debug.Log("[WL816a Water]\n" + sb.ToString());
|
||
|
|
}
|
||
|
|
}
|