protected T CreateTipPanel <T>(int uitag, Transform parentTrans, UIDataParent UIDataParent = null,
                                       bool isClear = false)
            where T : UIPanelParent
        {
            AFUIAttribute uiAttri = UIManager.Instance.GetClassData(uitag).Attribute as AFUIAttribute;

            if (resLoader == null)
            {
                resLoader = ResLoader.Allocate();
            }

            GameObject panel   = resLoader.InstantiateObjectSync(UIManager.Instance.GetResFrom(uiAttri.UIPath), uiAttri.UIPath, parentTrans, isClear);
            T          scripts = panel.GetComponent <T>();

            if (scripts == null)
            {
                scripts = panel.AddComponent <T>();
            }
            scripts.Open(uitag, uiAttri.UIPath, UIDataParent, UIManager.Instance.GetResFrom(uiAttri.UIPath), null);
            return(scripts);
        }
Exemple #2
0
        //此方法可用来创建panel,也可以刷新panel(不能重复创建panel),重复创建一般是子面板,在父面板中调用创建子面板方法即可
        public T OpenUI <T>(int UITag, Transform parent, UIDataParent UIDataParent = null,
                            bool isClear = false) where T : UIPanelParent
        {
            AFUIAttribute uiAttri     = GetClassData(UITag).Attribute as AFUIAttribute;
            string        scriptsName = typeof(T).ToString();

            if (ScriptsNameToPanel.ContainsKey(scriptsName) && ScriptsNameToPanel[scriptsName].JudgePath(uiAttri.UIPath))
            {
                ScriptsNameToPanel[scriptsName].transform.SetParent(parent);
                ScriptsNameToPanel[scriptsName].RefreshUIByData(UIDataParent);
                if (!UITagToScriptsName.ContainsKey(UITag))
                {
                    UITagToScriptsName[UITag] = scriptsName;
                }
                ScriptsNameToPanel[scriptsName].Show();
                //显示
                return(ScriptsNameToPanel[scriptsName] as T);
            }
            ResFromType resFromType = GetResFrom(uiAttri.UIPath);
            GameObject  panel       = resLoader.InstantiateObjectSync(resFromType, uiAttri.UIPath, parent, isClear);
            T           scripts     = panel.GetComponent <T>();

            if (scripts == null)
            {
                scripts = panel.AddComponent <T>();
            }
            scripts.Open(UITag, uiAttri.UIPath, UIDataParent, resFromType);
            if (ScriptsNameToPanel.ContainsKey(scriptsName))
            {
                ScriptsNameToPanel[scriptsName] = scripts as UIPanelParent;
            }
            else
            {
                ScriptsNameToPanel.Add(scriptsName, scripts as UIPanelParent);
            }
            UITagToScriptsName[UITag] = scriptsName;
            return(scripts);
        }
Exemple #3
0
 public void LoadPrefabFromLocalAB()
 {
     //从AB同步加载prefab,这里只测试了本地加载,加载来源配置要设置为streamasset
     Obj.Add(resLoader.InstantiateObjectSync(ResFromType.ABRes, "Assets/ResForAB/ABMain/Prefabs/ABLoadTestPre.prefab", UIPar, true));
 }