diff options
| author | yum <yum.food.vr@gmail.com> | 2026-01-18 10:59:11 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-01-18 10:59:11 -0800 |
| commit | 29fcaf34e1e6932379714ec3f2adffbbd487810e (patch) | |
| tree | b072e02419ccf7e48abd01978c33427bafd3fcef /Scripts/Impostors.cs | |
| parent | 50387110ee7ef1037fce6efabf4a1ea02be45259 (diff) | |
Impostors: generate assets based on hierarchy path
Diffstat (limited to 'Scripts/Impostors.cs')
| -rwxr-xr-x | Scripts/Impostors.cs | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/Scripts/Impostors.cs b/Scripts/Impostors.cs index 29d92d0..1214b8f 100755 --- a/Scripts/Impostors.cs +++ b/Scripts/Impostors.cs @@ -28,7 +28,7 @@ public class Impostors : MonoBehaviour public bool HasImpostor => impostorObject != null; private float Radius => sphere_radius_ * Mathf.Max(transform.lossyScale.x, transform.lossyScale.y, transform.lossyScale.z); - private const string OutputFolder = "Assets/yum_food/3ner/Impostor_Generated"; + private string OutputFolder => GetOutputFolder(); void OnEnable() => Camera.onPreRender += UpdateMainCameraPos; void OnDisable() => Camera.onPreRender -= UpdateMainCameraPos; @@ -59,6 +59,24 @@ public class Impostors : MonoBehaviour } } + string GetOutputFolder() + { + string hierarchyPath = GetHierarchyPath(); + return $"Assets/yum_food/3ner/Impostor_Generated/{hierarchyPath}"; + } + + string GetHierarchyPath() + { + string path = gameObject.name; + Transform parent = transform.parent; + while (parent != null) + { + path = parent.name + "/" + path; + parent = parent.parent; + } + return path; + } + Vector3 PlaneToHemiOctahedron(int gridX, int gridY) { float x = (gridX / (float)(gridResolution - 1)) * 2f - 1f; @@ -437,9 +455,18 @@ public class Impostors : MonoBehaviour { if (!AssetDatabase.IsValidFolder(OutputFolder)) { - if (!AssetDatabase.IsValidFolder("Assets/yum_food/3ner")) - AssetDatabase.CreateFolder("Assets/yum_food", "3ner"); - AssetDatabase.CreateFolder("Assets/yum_food/3ner", "Impostor_Generated"); + string[] pathParts = OutputFolder.Split('/'); + string currentPath = ""; + for (int i = 0; i < pathParts.Length; i++) + { + string parentPath = i == 0 ? "" : string.Join("/", pathParts, 0, i); + currentPath = i == 0 ? pathParts[0] : $"{parentPath}/{pathParts[i]}"; + if (!AssetDatabase.IsValidFolder(currentPath)) + { + string folderName = pathParts[i]; + AssetDatabase.CreateFolder(parentPath, folderName); + } + } } string baseName = gameObject.name.Replace(" ", "_"); |
