コード例 #1
0
        /// <summary>
        /// 找到所以在这个UI界面下的UI组件
        /// </summary>
        /// <param name="trans">界面的transform</param>
        /// <param name="parent">界面父类节点</param>
        /// <param name="dicAllUIObject">所有界面里的ui组件</param>
        public static void FindAllUIObjects(Transform trans, IXUIObject parent, ref Dictionary <string, XUIObjectBase> dicAllUIObject)
        {
            int i = 0;

            while (i < trans.childCount)
            {
                Transform     child     = trans.GetChild(i);
                XUIObjectBase component = child.GetComponent <XUIObjectBase>();
                if (component == null)
                {
                    goto IL_67;
                }
                //如果不是ListItem就加到dicAllUIObject里面
                if (component.GetType().GetInterface("IXUIListItem") == null)
                {
                    if (dicAllUIObject.ContainsKey(component.name))
                    {
                        Debug.LogError("m_dicId2UIObject.ContainsKey:" + LocalWidgetTool.GetUIObjectId(component));
                    }
                    dicAllUIObject[component.name] = component;
                    component.parent = parent;
                    goto IL_67;
                }
IL_6F:
                i++;
                continue;
IL_67:
                LocalWidgetTool.FindAllUIObjects(child, parent, ref dicAllUIObject);
                goto IL_6F;
            }
        }
コード例 #2
0
ファイル: WidgetFactory.cs プロジェクト: ly774508966/GameDemo
        /// <summary>
        /// 查找节点下所有的UI组件,缓存到字典里面
        /// </summary>
        /// <param name="trans"></param>
        /// <param name="parent"></param>
        /// <param name="dicAllUIObjects"></param>
        public static void FindAllUIObjects(Transform trans, IXUIObject parent, ref Dictionary <string, XUIObjectBase> dicAllUIObjects)
        {
            int i = 0;

            while (i < trans.childCount)
            {
                Transform     child     = trans.GetChild(i);
                XUIObjectBase component = child.GetComponent <XUIObjectBase>();
                if (!(null != component))
                {
                    goto IL_85;
                }
                if (component.GetType().GetInterface("IXUIListItem") == null)
                {
                    if (dicAllUIObjects.ContainsKey(component.name))
                    {
                        Debug.Log(component.name);
                        Debug.LogError("m_dicId2UIObject.ContainsKey:" + WidgetFactory.GetUIObjectId(component));
                    }
                    dicAllUIObjects[component.name] = component;
                    component.Parent = parent;
                    goto IL_85;
                }
                else
                {
                    Debug.Log("fdsfd");
                }
IL_8F:
                i++;
                continue;
IL_85:
                WidgetFactory.FindAllUIObjects(child, parent, ref dicAllUIObjects);
                goto IL_8F;
            }
        }