-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneHierarchyDumper.cs
More file actions
39 lines (33 loc) · 1.22 KB
/
Copy pathSceneHierarchyDumper.cs
File metadata and controls
39 lines (33 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// 28/11/2025 AI-Tag
// This was created with the help of Assistant, a Unity Artificial Intelligence product.
using System;
using UnityEditor;
using UnityEngine;
using System.IO;
public class SceneHierarchyDumper : MonoBehaviour
{
public string fileName = "SceneHierarchy.txt";
void Start()
{
string path = Application.dataPath + "/" + fileName;
using (StreamWriter writer = new StreamWriter(path))
{
// Get all root GameObjects in the scene
var rootObjects = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
foreach (var rootObject in rootObjects)
{
DumpHierarchy(writer, rootObject.transform, 0);
}
}
Debug.Log("Scene hierarchy dumped to: " + path);
}
void DumpHierarchy(StreamWriter writer, Transform obj, int depth)
{
string indent = new string(' ', depth * 2);
writer.WriteLine($"{indent}{obj.name} (Position: {obj.position}, Rotation: {obj.rotation.eulerAngles}, Scale: {obj.localScale})");
foreach (Transform child in obj)
{
DumpHierarchy(writer, child, depth + 1);
}
}
}