Esempio n. 1
0
        protected override void Awake()
        {
            base.Awake();
            if (m_btnShowMenu != null)
            {
                UGUIEventHandler.AddListener(m_btnShowMenu.gameObject, UGUIEventType.POINTER_CLICK, OnShowMenu);
            }

            if (m_btnHideMenu != null)
            {
                UGUIEventHandler.AddListener(m_btnHideMenu.gameObject, UGUIEventType.POINTER_CLICK, OnHideMenu);
            }

            if (m_txtSelectedItem != null)
            {
                UGUIEventHandler.AddListener(m_txtSelectedItem.gameObject, UGUIEventType.POINTER_CLICK, OnMenuStateChanged);
            }

            if (m_imgBackground != null)
            {
                UGUIEventHandler.AddListener(m_imgBackground.gameObject, UGUIEventType.POINTER_CLICK, OnMenuStateChanged);
            }

            m_transCachedTrans = GetComponent <RectTransform>();

            ////---------------test code
            //List<string> itemList = new List<string>{ "Item A", "Item B", "Item C", "Item D", "Item E", "Item F", "Item G", "Item H" };
            //AddMultiItem(itemList);

            HideMenuWithoutAni();
        }
        public DropDownMenuItem Copy(ScrollRect scrollRect = null)
        {
            GameObject newItemObj = GameObject.Instantiate(gameObject) as GameObject;

            newItemObj.transform.SetParent(gameObject.transform.parent, false);
            newItemObj.SetActive(true);
            DropDownMenuItem newItemComp = newItemObj.GetComponent <DropDownMenuItem>();

            UGUIEventHandler.AddListener(newItemComp.ItemText.gameObject, UGUIEventType.POINTER_CLICK, newItemComp.OnItemSelected);
            if (scrollRect != null)
            {
            }
            return(newItemComp);
        }