备份CatanBuilding瘦身独立工程
This commit is contained in:
68
Assets/Scripts/UI/Albun/ExchangePictureItem.cs
Normal file
68
Assets/Scripts/UI/Albun/ExchangePictureItem.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using cfg;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ExchangePictureItem : MonoBehaviour
|
||||
{
|
||||
public GameObject selected;
|
||||
public Button btn_click;
|
||||
public Action<ExchangePictureItem> action;
|
||||
public PictureAttribute pictureAttribute;
|
||||
public int index;
|
||||
bool isShow;
|
||||
public ExchangePictureItemData itemData;
|
||||
public void Awake()
|
||||
{
|
||||
pictureAttribute = transform.Find("Item").GetComponent<PictureAttribute>();
|
||||
btn_click = transform.Find("Item").GetComponent<Button>();
|
||||
selected = transform.Find("Item/selected").gameObject;
|
||||
if (isShow)
|
||||
{
|
||||
Show();
|
||||
}
|
||||
isShow = true;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
btn_click.onClick.AddListener(OnClick);
|
||||
}
|
||||
|
||||
public void SetData(ExchangePictureItemData _data, Action<ExchangePictureItem> _action)
|
||||
{
|
||||
itemData = _data;
|
||||
index = _data.index;
|
||||
action = _action;
|
||||
if (isShow)
|
||||
{
|
||||
Show();
|
||||
}
|
||||
isShow = true;
|
||||
}
|
||||
void Show()
|
||||
{
|
||||
pictureAttribute.Init(itemData.data);
|
||||
SetSelected(itemData.isSelect);
|
||||
}
|
||||
public void SetSelected(bool isSelect)
|
||||
{
|
||||
selected.SetActive(isSelect);
|
||||
}
|
||||
|
||||
public void OnClick()
|
||||
{
|
||||
action?.Invoke(this);
|
||||
}
|
||||
}
|
||||
public class ExchangePictureItemData
|
||||
{
|
||||
public Picture data;
|
||||
public int index;
|
||||
public bool isSelect;
|
||||
public ExchangePictureItemData(int index, Picture data)
|
||||
{
|
||||
this.index = index;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user