/// <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;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 根据名字获取UIObject
        /// </summary>
        /// <param name="strName"></param>
        /// <returns></returns>
        public IXUIObject GetUIObject(string strName)
        {
            IXUIObject result;

            if (null == strName)
            {
                result = null;
            }
            else
            {
                string key = strName;
                int    num = strName.LastIndexOf('/');
                if (num >= 0)
                {
                    key = strName.Substring(num + 1);
                }
                XUIObjectBase xUIObjectBase = null;
                if (this.m_dicId2UIObject.TryGetValue(key, out xUIObjectBase))
                {
                    result = xUIObjectBase;
                }
                else
                {
                    result = null;
                }
            }
            return(result);
        }
Esempio n. 3
0
        /// <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;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 初始化UIManager,注册UI事件监听,和UIHighlightCamera
        /// </summary>
        /// <param name="uiTool"></param>
        /// <param name="uiRoot"></param>
        /// <returns></returns>
        public override bool Init(IXUITool uiTool, Transform uiRoot)
        {
            bool result;

            if (null == uiTool || null == uiRoot)
            {
                result = false;
            }
            else
            {
                if (!base.Init(uiTool, uiRoot))
                {
                    this.m_log.Error("false == base.Init(uiTool,uiRoot)");
                    result = false;
                }
                else
                {
                    base.RegisterUIEventHandler(UnityGameEntry.Instance.gameObject);
                    base.RegisterLoadResAsynEventHandler(new LoadTextureAsynEventHandler(ResourceManager.singleton.LoadTexture));
                    base.RegisterTipShowEventHandler(new TipShowEventHandler(this.TipShow));
                    base.RegisterTipGetterEventHandler(new TipGetterEventHandler(this.GetTip));
                    base.RegisterAddListItemEventHandler(new AddListItemEventHandler(this.OnAddListItem));
                    XUIObjectBase.RegisterClickFilter(new FilterUIEventHandler(this.OnUIObjectEventFilter));
                    XLog.Log.Debug("UIManager Init Success!");
                    Transform transform = uiRoot.transform.parent.Find("CameraHighLight");
                    if (transform != null)
                    {
                        this.m_UIHightLightCamera = transform.gameObject.GetComponent <Camera>();
                    }
                    result = true;
                }
            }
            return(result);
        }
Esempio n. 5
0
    public override IXUIObject GetUIObject(string strPath)
    {
        if (strPath == null)
        {
            return(null);
        }
        string key = strPath;
        int    num = strPath.LastIndexOf('/');

        if (num >= 0)
        {
            key = strPath.Substring(num + 1);
        }
        XUIObjectBase result = null;

        if (this.m_dicId2UIObject.TryGetValue(key, out result))
        {
            return(result);
        }
        return(null);
    }