コード例 #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);
 }