diff --git a/Assets/Scripts/Editor/WarehouseSetup.cs b/Assets/Scripts/Editor/WarehouseSetup.cs new file mode 100644 index 0000000..4d67331 --- /dev/null +++ b/Assets/Scripts/Editor/WarehouseSetup.cs @@ -0,0 +1,76 @@ +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEngine; + +namespace SinoWms.EditorTools +{ + /// + /// 캐릭터가 돌아다닐 창고 환경(외벽 + 선반 랙)을 구성한다. + /// 메뉴 SinoWMS/Setup Warehouse. 바닥(Ground)은 PlaygroundSetup에서 생성된 것을 사용한다. + /// 모든 오브젝트에 콜라이더가 있어 캐릭터가 통과하지 못한다. + /// + public static class WarehouseSetup + { + private const float Half = 25f; // 바닥 50x50 기준 절반 + private const float WallH = 3f; + private const float WallT = 0.5f; + + [MenuItem("SinoWMS/Setup Warehouse")] + public static void Setup() + { + var root = GameObject.Find("Warehouse") ?? new GameObject("Warehouse"); + + // ---- 외벽 4면 ---- + var walls = ChildContainer(root, "Walls"); + var wallMat = MakeMaterial(new Color(0.78f, 0.78f, 0.82f)); + MakeBox(walls, "Wall_N", new Vector3(0, WallH / 2, Half), new Vector3(2 * Half, WallH, WallT), wallMat); + MakeBox(walls, "Wall_S", new Vector3(0, WallH / 2, -Half), new Vector3(2 * Half, WallH, WallT), wallMat); + MakeBox(walls, "Wall_E", new Vector3(Half, WallH / 2, 0), new Vector3(WallT, WallH, 2 * Half), wallMat); + MakeBox(walls, "Wall_W", new Vector3(-Half, WallH / 2, 0), new Vector3(WallT, WallH, 2 * Half), wallMat); + + // ---- 선반 랙 (Z축으로 길게, 중앙 통로 비움) ---- + var racks = ChildContainer(root, "Racks"); + var rackMat = MakeMaterial(new Color(0.85f, 0.45f, 0.15f)); // 주황(창고 랙 느낌) + float[] rows = { -16f, -8f, 8f, 16f }; + const float rackH = 2.5f, rackDepth = 1.5f, rackLen = 36f; + foreach (float x in rows) + { + string side = x < 0 ? "L" : "R"; + MakeBox(racks, $"Rack_{side}{Mathf.Abs(x):0}", + new Vector3(x, rackH / 2, 0f), + new Vector3(rackDepth, rackH, rackLen), rackMat); + } + + EditorSceneManager.MarkSceneDirty(root.scene); + Selection.activeGameObject = root; + Debug.Log("[WarehouseSetup] 완료. Play 후 캐릭터로 통로를 돌아다녀 보세요."); + } + + private static GameObject ChildContainer(GameObject parent, string name) + { + var t = parent.transform.Find(name); + if (t != null) return t.gameObject; + var go = new GameObject(name); + go.transform.SetParent(parent.transform, false); + return go; + } + + private static void MakeBox(GameObject parent, string name, Vector3 pos, Vector3 scale, Material mat) + { + if (parent.transform.Find(name) != null) return; // 이미 있으면 건너뜀 + + var box = GameObject.CreatePrimitive(PrimitiveType.Cube); // BoxCollider 포함 + box.name = name; + box.transform.SetParent(parent.transform, false); + box.transform.localPosition = pos; + box.transform.localScale = scale; + box.GetComponent().sharedMaterial = mat; + } + + private static Material MakeMaterial(Color color) + { + var shader = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard"); + return new Material(shader) { color = color }; + } + } +} diff --git a/Assets/Scripts/Editor/WarehouseSetup.cs.meta b/Assets/Scripts/Editor/WarehouseSetup.cs.meta new file mode 100644 index 0000000..62223c2 --- /dev/null +++ b/Assets/Scripts/Editor/WarehouseSetup.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: e7789607004404110a0cbb35327f9a2c \ No newline at end of file