第一次提交
This commit is contained in:
63
Assets/Scripts/UI/UIAudioTriggerPanel.cs
Normal file
63
Assets/Scripts/UI/UIAudioTriggerPanel.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UIAudioTriggerPanel : 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/audioTriggerItem");
|
||||
if (obj == null)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("audioTriggerItem.prefabʧ<62><CAA7>");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject go = Instantiate(obj) as GameObject; ;
|
||||
go.transform.SetParent(itemParent, false);
|
||||
UIAudioTriggerItem item = go.GetComponent<UIAudioTriggerItem>();
|
||||
item.itemIdx = itemParent.childCount;
|
||||
}
|
||||
|
||||
public void AddItem(Vector2Int pos, int radius, string name)
|
||||
{
|
||||
Object obj = Resources.Load("Prefabs/audioTriggerItem");
|
||||
if (obj == null)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("audioTriggerItem.prefabʧ<62><CAA7>");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject go = Instantiate(obj) as GameObject; ;
|
||||
go.transform.SetParent(itemParent, false);
|
||||
UIAudioTriggerItem item = go.GetComponent<UIAudioTriggerItem>();
|
||||
item.itemIdx = itemParent.childCount;
|
||||
MapManager.Instance.SetCurAudioTriggerCenterPoint(item.itemIdx, radius);
|
||||
item.txtPos.text = $"{pos.x},{pos.y}";
|
||||
item.txtRadius.text = radius.ToString();
|
||||
item.txtName.text = name;
|
||||
MapManager.Instance.CreateSpecialPoint(pos.x, pos.y, MapManager.EditCellType.AudioTrigger);
|
||||
}
|
||||
|
||||
public void RemoveAll()
|
||||
{
|
||||
int count = itemParent.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
DestroyImmediate(itemParent.GetChild(0).gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user