using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UIRelivesPanel : MonoBehaviour { [HideInInspector] public InputField curActiveInput; public Transform itemParent; public Button btnAdd; // Start is called before the first frame update void Start() { btnAdd.onClick.AddListener(AddItem); } void AddItem() { Object obj = Resources.Load("Prefabs/reliveItem"); if (obj == null) { UIWindow.Instance.ShowMessage("reliveItem.prefabʧ°Ü"); return; } Vector2Int newPos = MapManager.Instance.GetCameraPos(); GameObject go = Instantiate(obj) as GameObject; ; go.transform.SetParent(itemParent, false); UIReliveItem item = go.GetComponent(); item.reliveIdx = itemParent.childCount; item.editCellType = MapManager.EditCellType.ReliveCell; item.SetItemPos(newPos); MapManager.Instance.CreateSpecialPoint(newPos, item); } public void AddItem(int reliveType, int mapId, Vector2Int pos, int radius, int realMapId) { Object obj = Resources.Load("Prefabs/reliveItem"); if (obj == null) { UIWindow.Instance.ShowMessage("safeAreaItem.prefabʧ°Ü"); return; } GameObject go = Instantiate(obj) as GameObject; ; go.transform.SetParent(itemParent, false); UIReliveItem item = go.GetComponent(); item.dropType.value = reliveType; item.txtMapId.text = mapId.ToString(); item.txtPos.text = $"{pos.x},{pos.y}"; item.txtRadius.text = radius.ToString(); item.reliveIdx = itemParent.childCount; if (mapId != realMapId) return; item.editCellType = MapManager.EditCellType.ReliveCell; MapManager.Instance.SetReliveCenterPoint(item.reliveIdx, radius); MapManager.Instance.CreateSpecialPoint(pos, item); } public void RemoveAll() { int count = itemParent.childCount; for (int i = 0; i < count; i++) { DestroyImmediate(itemParent.GetChild(0).gameObject); } } }