예제 #1
0
 public virtual void Attach(ViewLevel viewLevel, UView beAttchedView)
 {
     UIMgr = beAttchedView?.UIMgr;
     ParentView?.SubViews.Remove(this);
     if (viewLevel == ViewLevel.Root)
     {
         ParentView = beAttchedView;
         RootView   = beAttchedView;
         ViewLevel  = ViewLevel.Main;
         RectTrans.SetParent(RootView?.CanvasTrans);
         UIMgr.AddToMainViews(this);
         UIMgr.AddToGroupViews(this);
     }
     else if (viewLevel == ViewLevel.Main)
     {
         ParentView = beAttchedView;
         RootView   = beAttchedView.RootView;
         ViewLevel  = ViewLevel.Sub;
         RectTrans.SetParent(RootView?.CanvasTrans);
         UIMgr.AddToGroupViews(this);
         //移动到父节点下面
         Trans.SetSiblingIndex(ParentView.Trans.GetSiblingIndex() + ParentView.SubViews.Count + 1);
     }
     else
     {
         CLog.Error("无法挂载到:" + viewLevel);
     }
     ParentView.SubViews.Add(this);
 }
예제 #2
0
        /// <summary>
        /// 将界面挂到其他界面下
        /// </summary>
        public override void Attach(BaseView parentView, BaseView rootView, Object mono)
        {
            base.Attach(parentView, rootView, mono);
            // 有利于找到UIprefab问题
            if (RectTrans == null)
            {
                CLog.Error("RectTrans没有,没有Awake?");
            }
            if (rootView != null)
            {
                RectTrans.SetParent(this.RootView.CanvasTrans);
            }

            RectTrans.localScale         = sourceLocalScale;
            RectTrans.anchorMax          = sourceAnchorMax;
            RectTrans.anchorMin          = sourceAnchorMin;
            RectTrans.sizeDelta          = sourceSizeData;
            Trans.localPosition          = sourceLocalPos;
            RectTrans.anchoredPosition   = sourceAnchoredPosition;
            RectTrans.anchoredPosition3D = sourceAnchoredPosition3D;
        }