57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
|
|
public class PopMenuItemLogic : UIItemBase {
|
|
|
|
public Text m_MenuItemLabel;
|
|
public delegate void MenuItemOnClicked();
|
|
private MenuItemOnClicked deleMenuItemOnClicked; // 响应函数托管
|
|
|
|
public class InitMenuInfo
|
|
{
|
|
public string strLabel;
|
|
public MenuItemOnClicked funcItemOnClicked;
|
|
|
|
public InitMenuInfo(string str, MenuItemOnClicked itemOnClicked)
|
|
{
|
|
strLabel = str;
|
|
funcItemOnClicked = itemOnClicked;
|
|
}
|
|
}
|
|
|
|
public override void Show(Hashtable hash)
|
|
{
|
|
base.Show();
|
|
|
|
var menuInfo = (InitMenuInfo)hash["InitObj"];
|
|
if (menuInfo != null)
|
|
InitMenuItem(menuInfo.strLabel, menuInfo.funcItemOnClicked);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 菜单项点击事件
|
|
/// </summary>
|
|
public void OnClicked()
|
|
{
|
|
MenuItemOnClicked temp = deleMenuItemOnClicked;
|
|
deleMenuItemOnClicked = null;
|
|
if (temp != null)
|
|
{
|
|
temp();
|
|
UIManager.CloseUI(UIInfo.PopMenuRoot);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化菜单项信息
|
|
/// </summary>
|
|
/// <param name="strLabel">文字</param>
|
|
/// <param name="funcItemOnClicked">响应函数</param>
|
|
public void InitMenuItem(string strLabel, MenuItemOnClicked funcItemOnClicked)
|
|
{
|
|
m_MenuItemLabel.text = strLabel;
|
|
deleMenuItemOnClicked = funcItemOnClicked;
|
|
}
|
|
}
|