Beispiel #1
0
        /// <summary>
        /// 带Window的UI初始化,初始化成功返回true
        /// </summary>
        public bool Init <T> (UIParam uiParam) where T : WindowBase, new()
        {
            param = uiParam;
            //根据path加载
            var obj = Resources.Load <GameObject>(Path);

            if (obj is null)
            {
                return(false);
            }

            UIGameObject = obj;
            UICanvas     = UIGameObject.AddComponent <Canvas>();
            UIGameObject.AddComponent <CanvasGroup>();
            UICanvas.renderMode = RenderMode.ScreenSpaceOverlay;

            //set UI name:
            UIGameObject.name = ID.ToString();

            ResetTransform();

            Window = new T();
            Window?.Init();

            return(true);
        }
Beispiel #2
0
 /// <summary>
 /// 通过此构造UI实例
 /// </summary>
 public UIBase(UIParam param)
 {
     if (!Init(param))
     {
         Tools.Log.Error($"load faild:{GetType().Name}");
         return;
     }
 }
Beispiel #3
0
        /// <summary>
        /// 不带Window的UI初始化
        /// </summary>
        public bool Init(UIParam uiParam)
        {
            param = uiParam;
            //#根据path加载,改成AssetsManager
            var obj = Resources.Load <GameObject>(Path);

            if (obj is null)
            {
                return(false);
            }

            UIGameObject = obj;
            UICanvas     = UIGameObject.AddComponent <Canvas>();
            UIGameObject.AddComponent <CanvasGroup>();
            UICanvas.renderMode = RenderMode.ScreenSpaceOverlay;

            ResetTransform();

            Window = UIGameObject.GetComponent <WindowBase>();
            Window?.Init();

            return(true);
        }