public void Load() { uiMvcVessel.Clear(); List <Type> types = Game.EventSystem.GetTypes(); foreach (Type type in types) { object[] attrs = type.GetCustomAttributes(typeof(UIFactoryAttribute), true); if (attrs.Length == 0) { attrs = type.GetCustomAttributes(typeof(UIComponentAttribute), true); if (attrs.Length == 0) { continue; } } Type attrType = attrs[0].GetType(); if (typeof(UIFactoryAttribute) == attrType) { UIFactoryAttribute factoryAttribute = attrs[0] as UIFactoryAttribute; uiMvcVessel.AddUIMvcVessel(UIMvcVesselType.Factory, factoryAttribute.Type, type); } else if (typeof(UIComponentAttribute) == attrType) { UIComponentAttribute componentAttribute = attrs[0] as UIComponentAttribute; uiMvcVessel.AddUIMvcVessel(UIMvcVesselType.Componet, componentAttribute.Type, type); } } }
void OnEnable() { Debug.Log("MenuTest.Initialize()"); m_isInitialized = UIComponentAttribute.InitComponents(this.gameObject, this); if (!m_isInitialized) { Debug.LogError("Initialize failed!"); return; } m_button.onClick.Add(new EventDelegate() { target = this, methodName = "OnButtonClick" }); m_lbButton.text = "Change!"; }