85 lines
2.3 KiB
C#
85 lines
2.3 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using UnityEngine.Events;
|
|||
|
using GCGame.Table;
|
|||
|
|
|||
|
// 带物品容器的选择提示面板
|
|||
|
public class ItemContainerTipCtr : MonoBehaviour {
|
|||
|
|
|||
|
public UIBackRayBehind bgMask; // 背景
|
|||
|
public Button confirmBtn; // 确认按钮
|
|||
|
public Button cancelBtn; // 取消按钮
|
|||
|
public Text confirmDesc; // 确认按钮描述
|
|||
|
public Text cancelDesc; // 取消按钮描述
|
|||
|
public UIContainerBase container; // 显示容器
|
|||
|
public GameObject titleGO; // 标题物品
|
|||
|
public Text title; // 标题描述
|
|||
|
public Text desc; // 提示描述
|
|||
|
private UnityAction confirmCallBack; // 确认按钮回调
|
|||
|
private UnityAction cancelCallBack; // 取消按钮回调
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
bgMask._BackClick.AddListener(OnCancelClick);
|
|||
|
confirmBtn.onClick.AddListener(OnConfirmClick);
|
|||
|
cancelBtn.onClick.AddListener(OnCancelClick);
|
|||
|
}
|
|||
|
|
|||
|
public void ShowTip(string title, string desc, IEnumerable info, UnityAction onConfirm, UnityAction onCancel)
|
|||
|
{
|
|||
|
gameObject.SetActive(true);
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(title))
|
|||
|
{
|
|||
|
titleGO.gameObject.SetActive(true);
|
|||
|
this.title.text = title;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
titleGO.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
if(!string.IsNullOrEmpty(desc))
|
|||
|
{
|
|||
|
this.desc.gameObject.SetActive(true);
|
|||
|
this.desc.text = desc;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.desc.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
confirmCallBack = onConfirm;
|
|||
|
cancelCallBack = onCancel;
|
|||
|
|
|||
|
container.InitContentItem(info);
|
|||
|
}
|
|||
|
|
|||
|
private void OnConfirmClick()
|
|||
|
{
|
|||
|
if(confirmCallBack != null)
|
|||
|
{
|
|||
|
confirmCallBack.Invoke();
|
|||
|
}
|
|||
|
|
|||
|
Close();
|
|||
|
}
|
|||
|
|
|||
|
private void OnCancelClick()
|
|||
|
{
|
|||
|
if(cancelCallBack != null)
|
|||
|
{
|
|||
|
cancelCallBack.Invoke();
|
|||
|
}
|
|||
|
|
|||
|
Close();
|
|||
|
}
|
|||
|
|
|||
|
private void Close()
|
|||
|
{
|
|||
|
gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|