116 lines
5.6 KiB
C#
116 lines
5.6 KiB
C#
// WL-816h — ⑥ 기능 무영향 실측 (걷기 · 섬 확장 · 물 콜라이더) + 최종 PD 경로 캡처
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.Rendering.Universal;
|
|
using FIIsland = CryingSnow.FarmingIsland.Island;
|
|
|
|
public static class WL816h_Func
|
|
{
|
|
public static void Open()
|
|
{
|
|
UnityEditor.SceneManagement.EditorSceneManager.OpenScene(
|
|
"Assets/Scenes/InGame.unity", UnityEditor.SceneManagement.OpenSceneMode.Single);
|
|
}
|
|
public static void Start()
|
|
{
|
|
var go = GameObject.Find("~WL816hFunc");
|
|
if (go != null) Object.DestroyImmediate(go);
|
|
go = new GameObject("~WL816hFunc");
|
|
go.AddComponent<WL816h_FuncRunner>();
|
|
}
|
|
}
|
|
|
|
public class WL816h_FuncRunner : MonoBehaviour
|
|
{
|
|
static System.Text.StringBuilder sb;
|
|
static void L(string s) { sb.AppendLine(s); }
|
|
|
|
void Start() { StartCoroutine(Co()); }
|
|
|
|
IEnumerator Co()
|
|
{
|
|
sb = new System.Text.StringBuilder();
|
|
L("=== ⑥ 기능 무영향 (PD 경로 · 채택 상태) ===");
|
|
var op = SceneManager.LoadSceneAsync("Level01", LoadSceneMode.Additive);
|
|
while (op != null && !op.isDone) yield return null;
|
|
for (int i = 0; i < 7; i++) yield return new WaitForSeconds(1f);
|
|
|
|
// 물 — 콜라이더·메시가 그대로인가 (머티리얼만 바꿨다)
|
|
Renderer water = null;
|
|
foreach (var r in Object.FindObjectsByType<Renderer>(FindObjectsInactive.Exclude, FindObjectsSortMode.None))
|
|
if (r != null && r.gameObject.scene.name == "Level01" && r.name == "Water") water = r;
|
|
if (water != null)
|
|
{
|
|
var mc = water.GetComponent<MeshCollider>();
|
|
var mf = water.GetComponent<MeshFilter>();
|
|
L("물 : mat=" + water.sharedMaterial.name + " · MeshCollider=" + (mc != null ? ("있음 enabled=" + mc.enabled + " mesh=" + (mc.sharedMesh ? mc.sharedMesh.name : "없음")) : "없음")
|
|
+ " · MeshFilter=" + (mf != null && mf.sharedMesh ? mf.sharedMesh.name : "없음")
|
|
+ " · layer=" + water.gameObject.layer + " · pos=" + water.transform.position.ToString("F1")
|
|
+ " · scale=" + water.transform.localScale.ToString("F0"));
|
|
}
|
|
|
|
// 걷기 — FI 플레이어의 CharacterController 로 대각선 6 m
|
|
var cc = Object.FindFirstObjectByType<CharacterController>(FindObjectsInactive.Exclude);
|
|
if (cc != null)
|
|
{
|
|
var p0 = cc.transform.position;
|
|
var dir = new Vector3(1f, 0f, 1f).normalized;
|
|
float moved = 0f;
|
|
for (int i = 0; i < 120 && moved < 6f; i++)
|
|
{ cc.Move(dir * 0.05f + Vector3.down * 0.05f); moved += 0.05f; yield return null; }
|
|
var p1 = cc.transform.position;
|
|
L("걷기: " + p0.ToString("F2") + " → " + p1.ToString("F2")
|
|
+ " · 이동 " + Vector3.Distance(new Vector3(p0.x, 0, p0.z), new Vector3(p1.x, 0, p1.z)).ToString("F2") + " m"
|
|
+ " · grounded=" + cc.isGrounded);
|
|
}
|
|
else L("걷기: CharacterController 없음(세이브 상태에 따라 없을 수 있다)");
|
|
|
|
// 섬 확장 — 타일 하나 잠갔다 다시 열기 (풀이 따라오나)
|
|
int before = WL.Look.Farm.WLIslandGrass.LastLog != null ? 1 : 0;
|
|
var islands = Object.FindObjectsByType<FIIsland>(FindObjectsInactive.Exclude, FindObjectsSortMode.None);
|
|
L("풀(확장 전): " + WL.Look.Farm.WLIslandGrass.LastLog + " · 섬 타일 " + islands.Length);
|
|
FIIsland target = null;
|
|
foreach (var isl in islands) if (isl != null && isl.IsUnlocked && isl.gameObject.activeInHierarchy) target = isl;
|
|
if (target != null)
|
|
{
|
|
target.gameObject.SetActive(false);
|
|
yield return new WaitForSeconds(2f);
|
|
L("풀(1칸 잠금): " + WL.Look.Farm.WLIslandGrass.LastLog);
|
|
target.gameObject.SetActive(true);
|
|
yield return new WaitForSeconds(3f);
|
|
L("풀(다시 열기): " + WL.Look.Farm.WLIslandGrass.LastLog + " · 재생성 " + WL.Look.Farm.WLIslandLook.GrassRebuilds + "회");
|
|
}
|
|
|
|
// 최종 PD 경로 캡처
|
|
Camera live = null;
|
|
foreach (var c in Object.FindObjectsByType<Camera>(FindObjectsInactive.Exclude, FindObjectsSortMode.None))
|
|
{
|
|
if (!c.gameObject.activeInHierarchy || !c.enabled || c.targetTexture != null) continue;
|
|
if (c.name.StartsWith("~WL816h")) continue;
|
|
if (live == null || c.depth > live.depth) live = c;
|
|
}
|
|
L("최종 = " + Shot(live, "Screenshots_WL/WL816h/b_final_pd_path.png"));
|
|
L("SkyScope held=" + WL.Look.Farm.WLSkyScope.Held + " · " + WL.Look.Farm.WLSkyScope.LastLog);
|
|
|
|
System.IO.File.WriteAllText("AgentScripts/WL816h_FUNC.txt", sb.ToString());
|
|
Debug.Log("[816h func]\n" + sb);
|
|
}
|
|
|
|
static string Shot(Camera cam, string path)
|
|
{
|
|
if (cam == null) return "카메라 없음";
|
|
System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path));
|
|
var rt = new RenderTexture(1080, 1920, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
|
|
rt.antiAliasing = 1; rt.Create();
|
|
var pT = cam.targetTexture; var pA = RenderTexture.active;
|
|
cam.targetTexture = rt; cam.Render(); RenderTexture.active = rt;
|
|
var tex = new Texture2D(1080, 1920, TextureFormat.RGB24, false);
|
|
tex.ReadPixels(new Rect(0, 0, 1080, 1920), 0, 0); tex.Apply();
|
|
RenderTexture.active = pA; cam.targetTexture = pT;
|
|
System.IO.File.WriteAllBytes(path, tex.EncodeToPNG());
|
|
Object.DestroyImmediate(tex); rt.Release(); Object.DestroyImmediate(rt);
|
|
return path;
|
|
}
|
|
}
|