/// <summary> /// 递归 加载 UIBehavrious /// </summary>// /// _n 表示 不加入 UIManager 里 编程不会用到 /// _c 表示 犹如 背包系统的 多个 相同的 单元格的 管理方式 以 iterm 为单位 /// <param name="root"></param> void AdddBehaviours(Transform root) { for (int i = 0; i < root.childCount; i++) { Transform tmpChild = root.GetChild(i); if (tmpChild.name.EndsWith("_c")) { tmpChild.gameObject.AddComponent <UISubManager>(); } else { if (!tmpChild.name.EndsWith("_n")) { UIBehaviours tmpBehaviours = tmpChild.gameObject.AddComponent <UIBehaviours>(); tmpBehaviours.PanelName = panelName; } if (tmpChild.childCount > 0) { AdddBehaviours(tmpChild); } } } }
public UIBehaviours GetBehaviours(string childName) { GameObject tmpObj = GetGameObject(childName); UIBehaviours uiBeaviours = tmpObj.GetComponent <UIBehaviours>(); return(uiBeaviours); }
/// <summary> /// 查找 panle名字==transfoem.name /// </summary> /// <param name="childName"></param> /// <returns></returns> public UIBehaviours GetBehavirous(string childName) { //从这拿走 GameObject tmpObj = UIManage.Instance.GetGameObject(transform.name, childName); UIBehaviours tmpBehavious = tmpObj.GetComponent <UIBehaviours>(); return(tmpBehavious); }
public void AddToggleLisenter(string objName, UnityAction <bool> action) { UIBehaviours tmpBehavrours = GetUIComponent <UIBehaviours>(objName); if (tmpBehavrours != null) { tmpBehavrours.AddToggleLisenter(action); } }
public void AddInputFiledLisenter(string objName, UnityAction <string> action) { UIBehaviours tmpBehavrours = GetUIComponent <UIBehaviours>(objName); if (tmpBehavrours != null) { tmpBehavrours.AddInputFiledLisenter(action); } }
public void AddSliderLisenter(string objName, UnityAction <float> action) { UIBehaviours tmpBehavrours = GetUIComponent <UIBehaviours>(objName); if (tmpBehavrours != null) { tmpBehavrours.AddSliderLisenter(action); } }
public void AddButtonUpLisenter(string objName, UnityAction <BaseEventData> action) { UIBehaviours tmpBehavrours = GetUIComponent <UIBehaviours>(objName); if (tmpBehavrours != null) { tmpBehavrours.AddButtonUpLisenter(action); } }
public void AddSliderListener(string childName, UnityAction <float> action) { UIBehaviours tmpBehaviours = GetBehaviours(childName); if (tmpBehaviours != null) { tmpBehaviours.AddSliderListener(action); } }
public void AddButtonListener(string childName, UnityAction action) { UIBehaviours tmpBehaviours = GetBehaviours(childName); if (tmpBehaviours != null) { tmpBehaviours.AddButtonListener(action); } }
public void AddSliderLisenter(string childName, UnityAction <float> action) { UIBehaviours tmpBahavriou = GetBehavirous(childName); if (tmpBahavriou != null) { tmpBahavriou.AddSliderListener(action); } }
/// <summary> ///动态 添加事件 ///只要UIBehaviours不为空就可以添加 /// </summary> /// <param name="childName"></param> /// <param name="action"></param> public void AddButtonLisenter(string childName, UnityAction action) { //通过UIBase里的GetBehavirous方法获取控件的名字 UIBehaviours tmpBahavriou = GetBehavirous(childName); if (tmpBahavriou != null) { tmpBahavriou.AddButtonListener(action); } }
public void AddButtonLisenter(string objName, UnityAction action) { UIBehaviours tmpBehavrours = GetUIComponent <UIBehaviours>(objName); Debug.Log("AddButtonLisenter objName==" + objName); if (tmpBehavrours != null) { tmpBehavrours.AddButtonLisenter(action); } }
public void AddComponentToChild() { Transform[] childrens = GetComponentsInChildren <Transform>(); for (int i = 1; i < childrens.Length; i++) { if (!childrens[i].name.EndsWith("_n")) { UIBehaviours behav = childrens[i].GetComponent <UIBehaviours>(); if (behav == null) { behav = childrens[i].gameObject.AddComponent <UIBehaviours>(); behav.PanelName = this.name; } } } }
private void AddBehaviour(Transform panel) { //panel -- button -- text for (int i = 0; i < panel.childCount; i++) { Transform child = panel.GetChild(i); UIBehaviours behaviours = child.GetComponent <UIBehaviours>(); if (behaviours == null)//处理子节点 { child.gameObject.AddComponent <UIBehaviours>(); } if (child.childCount > 0)//处理孙节点 { AddBehaviour(child); } } }