Ejemplo n.º 1
0
    //registers a listener to a particular menu (and its children)
    public virtual void RegisterEventListener(GUIMenu menu, GUIEventListener listener)
    {
        //recurse on our children
        for (int i = 0; i < menu.m_MenuItems.Length; i++)
        {
            if (menu.m_MenuItems[i].m_SubMenu != null && menu.m_MenuItems[i].m_SubMenu.m_MenuItems != null)
            {
                if (menu.m_MenuItems[i].m_SubMenu.m_MenuItems.Length > 0)
                {
                    RegisterEventListener(menu.m_MenuItems[i].m_SubMenu, listener);
                }
            }
        }

        //first check if the menu has an entry in the listener dictionary already
        //if it doesnt create a new entry in the dictionary
        List <GUIEventListener> list;

        if (!m_Listeners.TryGetValue(menu, out list))
        {
            list = new List <GUIEventListener>();
            m_Listeners.Add(menu, list);
        }
        //add the listener
        list.Add(listener);
    }
Ejemplo n.º 2
0
    public static GUIEventListener Get(GameObject go)
    {
        GUIEventListener gUIEventListener = go.GetComponent <GUIEventListener>();

        if (gUIEventListener == null)
        {
            gUIEventListener = go.AddComponent <GUIEventListener>();
        }
        return(gUIEventListener);
    }
Ejemplo n.º 3
0
    public static GUIEventListener Get(GameObject go)
    {
        GUIEventListener component = go.GetComponent <GUIEventListener>();

        if (component == null)
        {
            component = go.AddComponent <GUIEventListener>();
        }
        return(component);
    }
Ejemplo n.º 4
0
        protected override void OnInit(object userData)
        {
            base.OnInit(userData);
            GUIEventListener.Get(gameObject).onClick = _ => {
                OnClose(true, userData);
            };

            //GetComponent<Button>().onClick.AddListener(()=> {
            //    this.OnClose(false, userData);
            //});
        }
Ejemplo n.º 5
0
        public void OpenInitChooseHeroForm()
        {
            CUIFormScript script = Singleton <CUIManager> .GetInstance().OpenForm(s_heroInitChooseFormPath, false, true);

            if (script != null)
            {
                this.heroDescTxt      = script.transform.Find("heroDescTxt").GetComponent <Text>();
                this.heroDescTxt.text = string.Empty;
                this.selectHeroBtn    = script.transform.Find("selectHeroBtn").gameObject;
                GUIEventListener.Get(this.selectHeroBtn).onClick += new GUIEventListener.VoidDelegate(this.OnConfirmChooseHero);
                this.selectHeroBtn.CustomSetActive(false);
                this.InitHeroPanel();
            }
        }
Ejemplo n.º 6
0
    private static GUIEventDispatcher MenuDispatcher = new GUIEventDispatcher();          //dispatcher that will fire off events

    public void RegisterEventListener(GUIEventListener listener)
    {
        MenuDispatcher.RegisterEventListener(this, listener);
    }
Ejemplo n.º 7
0
	private static GUIEventDispatcher MenuDispatcher = new GUIEventDispatcher();         //dispatcher that will fire off events
	
	public void RegisterEventListener(GUIEventListener listener)
	{
		MenuDispatcher.RegisterEventListener(this, listener);
	}
Ejemplo n.º 8
0
	//registers a listener to a particular menu (and its children)
	public virtual void RegisterEventListener(GUIMenu menu, GUIEventListener listener) {
	
		//recurse on our children
		for(int i = 0 ; i < menu.m_MenuItems.Length; i++)
		{
			if(menu.m_MenuItems[i].m_SubMenu != null && menu.m_MenuItems[i].m_SubMenu.m_MenuItems != null)
				if(menu.m_MenuItems[i].m_SubMenu.m_MenuItems.Length > 0)
					RegisterEventListener(menu.m_MenuItems[i].m_SubMenu,listener);
		}
		
		//first check if the menu has an entry in the listener dictionary already
		//if it doesnt create a new entry in the dictionary
		List<GUIEventListener> list;
		if (!m_Listeners.TryGetValue(menu, out list))
		{
			list = new List<GUIEventListener>();
			m_Listeners.Add(menu, list);
		}
		//add the listener
		list.Add(listener);
	}