33 lines
847 B
C#
33 lines
847 B
C#
|
using System;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
namespace ZXL
|
||
|
{
|
||
|
public class ConctrolItem : MonoBehaviour
|
||
|
{
|
||
|
public Button btnItem;
|
||
|
public Text txtItemName;
|
||
|
ConctrolType conctrolType;
|
||
|
private Action<ConctrolType> callback;
|
||
|
void Awake()
|
||
|
{
|
||
|
btnItem = GetComponent<Button>();
|
||
|
txtItemName = transform.FindChildDeep<Text>("txtItemName");
|
||
|
|
||
|
btnItem.onClick.AddListener(OnClickbtnItem);
|
||
|
}
|
||
|
|
||
|
private void OnClickbtnItem()
|
||
|
{
|
||
|
callback?.Invoke(conctrolType);
|
||
|
}
|
||
|
|
||
|
public void SetConctrol(ConctrolType conctrolType,Action<ConctrolType> callback)
|
||
|
{
|
||
|
this.callback = callback;
|
||
|
this.conctrolType = conctrolType;
|
||
|
txtItemName.text = conctrolType.ToString();
|
||
|
}
|
||
|
}
|
||
|
}
|