42 lines
1.7 KiB
C#
42 lines
1.7 KiB
C#
using UnityEngine;
|
|
using UnityEditor;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
public class DumpSceneHierarchy
|
|
{
|
|
[MenuItem("Tools/Dump Scene Hierarchy")]
|
|
public static void DumpHierarchy()
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (GameObject go in UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects())
|
|
{
|
|
DumpGameObject(go, sb, "");
|
|
}
|
|
File.WriteAllText("SceneHierarchy.txt", sb.ToString());
|
|
Debug.Log("Scene hierarchy dumped to SceneHierarchy.txt");
|
|
}
|
|
|
|
private static void DumpGameObject(GameObject go, StringBuilder sb, string indent)
|
|
{
|
|
sb.AppendLine($"{indent}- {go.name} (Active: {go.activeInHierarchy}, ActiveSelf: {go.activeSelf})");
|
|
|
|
var ping = go.GetComponent<PingClickHandler>();
|
|
if (ping != null) sb.AppendLine($"{indent} [PingClickHandler] pingIndex={ping.pingIndex}, nextPing={(ping.nextPing != null ? ping.nextPing.name : "null")}");
|
|
|
|
var shose = go.GetComponent<ShoseClickHandler>();
|
|
if (shose != null) sb.AppendLine($"{indent} [ShoseClickHandler] nextObject={(shose.nextObject != null ? shose.nextObject.name : "null")}");
|
|
|
|
var chanrao = go.GetComponent<ChanraoTuibuHandler>();
|
|
if (chanrao != null) sb.AppendLine($"{indent} [ChanraoTuibuHandler]");
|
|
|
|
var touch = go.GetComponent<TouchPositionHandler>();
|
|
if (touch != null) sb.AppendLine($"{indent} [TouchPositionHandler] next={(touch.nextTouchObject != null ? touch.nextTouchObject.name : "null")}");
|
|
|
|
foreach (Transform child in go.transform)
|
|
{
|
|
DumpGameObject(child.gameObject, sb, indent + " ");
|
|
}
|
|
}
|
|
}
|