using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using Games.GlobeDefine; using GCGame.Table; using GCGame; using Games.Item; public class GiftWordsRoot : MonoBehaviour { private Dictionary m_dialogs = new Dictionary() { {1,5129 }, {2,5130 }, {3,5131 }, }; public GameObject cloneBnt; public InputField inputDialog; int m_selectIndex = 1; GameItem m_gameItem; void Awake() { Hashtable add = new Hashtable(); add["name"] = "UseItemDialog"; Games.Events.MessageEventCallBack call = OnOpen; add["callFun"] = call; Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.OpenUseItemWithDialogWnd, add); Hashtable add1 = new Hashtable(); add1["name"] = "SendChatTo"; Games.Events.MessageEventCallBack call1 = SendChatTo; add1["callFun"] = call1; Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.SendMailInfoChatLink, add1); } public void OnOpen(Hashtable addparam, Hashtable sendparam) { if (sendparam == null) return; if (sendparam.ContainsKey("item") == false) return; GameItem item = (GameItem)sendparam["item"]; if(item==null) { UIManager.CloseUI(UIInfo.GiftWordsRoot); return; } m_gameItem = item; int i = 0; int firstkey = 0; foreach (var dialog in m_dialogs) { if (i == 0) firstkey = dialog.Key; i++; ClonedialogBtn(dialog.Key); } SelectDialog(firstkey); } void OnDestroy() { Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.OpenUseItemWithDialogWnd, "UseItemDialog"); Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.SendMailInfoChatLink, "SendChatTo"); } void ClonedialogBtn(int index) { if (cloneBnt == null) return; GameObject btnObj = Object.Instantiate(cloneBnt) as GameObject; if (btnObj == null) return; btnObj.SetActive(true); btnObj.transform.parent = cloneBnt.transform.parent; btnObj.transform.localPosition = Vector3.zero; btnObj.transform.localScale = cloneBnt.transform.localScale; Text ms = btnObj.GetComponentInChildren(); if(ms!=null) { Tab_StrDictionary pGoodNameDictionary = TableManager.GetStrDictionaryByID(m_dialogs[index], 0); if (pGoodNameDictionary != null) { ms.text = pGoodNameDictionary.StrDictionary; } } Button btn = btnObj.GetComponentInChildren