feat: 적치 슬롯 + 정답 판정
- PutawaySlot: 박스 스냅 배치 + 기대 품목 비교 → 패드 색(초록/빨강) - PickupController: 빈 슬롯에 적치 / 슬롯에서 재집기 / 'E: 적치' 힌트 - SlotSetup: 슬롯 4개 배치 + 박스별 기대 품목 매핑 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using SinoWms.Gameplay;
|
||||
|
||||
namespace SinoWms.EditorTools
|
||||
{
|
||||
/// <summary>
|
||||
/// 적치 슬롯을 창고에 배치한다. 각 슬롯은 바닥 패드 + 트리거 콜라이더 + 기대 품목을 가진다.
|
||||
/// 메뉴 <b>SinoWMS/Setup Slots</b>. Play 후 박스를 들고 슬롯에서 E키로 적치(정답=초록/오답=빨강).
|
||||
/// </summary>
|
||||
public static class SlotSetup
|
||||
{
|
||||
// 슬롯 위치와 기대 품목 (PickupDemoSetup의 박스 이름과 일치시켜 정답 구성)
|
||||
private static readonly (Vector3 pos, string expected)[] Slots =
|
||||
{
|
||||
(new Vector3(-6f, 0.03f, 8f), "박스 A (생수)"),
|
||||
(new Vector3(-2f, 0.03f, 8f), "박스 B (우유)"),
|
||||
(new Vector3(2f, 0.03f, 8f), "박스 C (라면)"),
|
||||
(new Vector3(6f, 0.03f, 8f), "박스 D (잡화)"),
|
||||
};
|
||||
|
||||
[MenuItem("SinoWMS/Setup Slots")]
|
||||
public static void Setup()
|
||||
{
|
||||
var container = GameObject.Find("PutawaySlots") ?? new GameObject("PutawaySlots");
|
||||
|
||||
for (int i = 0; i < Slots.Length; i++)
|
||||
{
|
||||
string slotName = $"Slot_{i + 1}";
|
||||
if (container.transform.Find(slotName) != null) continue;
|
||||
|
||||
var slotGo = new GameObject(slotName);
|
||||
slotGo.transform.SetParent(container.transform, false);
|
||||
slotGo.transform.localPosition = Slots[i].pos;
|
||||
|
||||
// 바닥 패드 (상태 색 표시)
|
||||
var pad = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
pad.name = "Pad";
|
||||
Object.DestroyImmediate(pad.GetComponent<BoxCollider>());
|
||||
pad.transform.SetParent(slotGo.transform, false);
|
||||
pad.transform.localScale = new Vector3(1.2f, 0.05f, 1.2f);
|
||||
pad.GetComponent<Renderer>().sharedMaterial =
|
||||
new Material(Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard"))
|
||||
{ color = new Color(1f, 0.82f, 0.3f) };
|
||||
|
||||
// 적치 감지용 트리거
|
||||
var trigger = slotGo.AddComponent<BoxCollider>();
|
||||
trigger.isTrigger = true;
|
||||
trigger.size = new Vector3(1.4f, 1.5f, 1.4f);
|
||||
trigger.center = new Vector3(0f, 0.75f, 0f);
|
||||
|
||||
var slot = slotGo.AddComponent<PutawaySlot>();
|
||||
var so = new SerializedObject(slot);
|
||||
so.FindProperty("pad").objectReferenceValue = pad.GetComponent<Renderer>();
|
||||
so.FindProperty("expectedLabel").stringValue = Slots[i].expected;
|
||||
so.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(container.scene);
|
||||
Selection.activeGameObject = container;
|
||||
Debug.Log("[SlotSetup] 완료. 박스를 들고 슬롯 위에서 E키로 적치하세요(정답=초록/오답=빨강).");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bab24c45943e84dc9bf7ace8f7d0d618
|
||||
Reference in New Issue
Block a user