Beispiel #1
0
        /// <summary>
        /// 规定任何同一个页面不可以同时开两个.如果一定要这么做,那么通过extra_index区分
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="page_name"></param>
        /// <returns></returns>
        public T OpenDialog <T>(string page_name, string extra_index = "") where T : UGUIWidget
        {
            UGUIPageData data = GameSettings.FindPageData(page_name);

            if (data == null)
            {
                Debug.LogError(typeof(T) + " not found or type does not patch!");
                return(default(T));
            }

            if (canvas == null)
            {
                Debug.LogError("No root canvas found");
                return(default(T));
            }

            T new_page = ResourceManager.Instance.CreateInstance <T>(data.prefab_path, canvas.transform);

            new_page.transform.localScale = Vector3.one;
            (new_page.transform as RectTransform).anchoredPosition = Vector2.zero;


            //TODO:暂时不考虑太多,只要打开就加入队列。关闭一个,自动把队列里面上一个恢复了。或者上一个批次恢复,这个是应该做的。
            //通过设置HideBatch字段,来实现这个效果。每次调用Hide方法,HideBatch+1,关闭一个上层窗体,则会将所有页面的HideBatch-1,恢复HideBatch为0的所有窗体(这是自动的)
            if (new_page != null)
            {
                new_page.name = string.IsNullOrEmpty(extra_index) ? page_name : page_name + "#" + extra_index;
                page_stack.Add(new_page);
                CheckHideOthers(new_page);
            }

            return(new_page);
        }
Beispiel #2
0
 public override void OnAwake()
 {
     foreach (var page in auto_load_pages)
     {
         UGUIPageData pd = GameSettings.FindPageData(page);
         MethodInfo   mi = typeof(UGUIManager).GetMethod("OpenDialog").MakeGenericMethod(System.Type.GetType(pd.type_index));
         mi.Invoke(this, new object[] { pd.name_index, "" });
     }
 }