Esempio n. 1
0
    private void ShrinkDepth(DrawCallData data)
    {
        int      start = data.DepthStart;
        UIWidget widget;
        UIWidget w;
        int      maxDepth = 0;

        for (int i = 0; i < data.widgets.Count; i++)
        {
            maxDepth = start;
            widget   = data.widgets[i];
            for (int j = 0; j < i; j++)
            {
                w = data.widgets[j];
                if (widget.depth != w.depth && w.depth >= maxDepth && CheckWidgetCollider(widget, w))
                {
                    maxDepth = w.depth + 1;
                }
            }
            if (widget.depth > maxDepth)
            {
                AddChange(widget, widget.depth, maxDepth, "[shrink]", data.simple.name);
                widget.depth = maxDepth;
            }
        }
        data.SetDirty(true);
        data.Sort();
        depthChangeExpand = true;
    }
Esempio n. 2
0
 private void AddDeltaDepth(DrawCallData data, int depth)
 {
     for (int i = 0; i < data.widgets.Count; i++)
     {
         UIWidget widget = data.widgets[i];
         AddChange(widget, widget.depth, widget.depth + depth, "[Add]", data.simple.name);
         widget.depth = widget.depth + depth;
     }
     data.SetDirty(true);
     depthChangeExpand = true;
 }
Esempio n. 3
0
    private static void CreateEmptyDC(int index, UIWidget w)
    {
        SimpleDC dc = new SimpleDC(true, null, w.panel);

        dcList.Insert(index, dc);
        DrawCallData dcData = new DrawCallData();

        dcData.simple = dc;
        dcData.AddW(w);
        allWidgetDic.Add(dc, dcData);
    }
Esempio n. 4
0
        public DrawCallData Clone()
        {
            DrawCallData d = new DrawCallData();

            d.simple = simple;
            foreach (var w in widgets)
            {
                d.widgets.Add(w);
            }
            d.SetDirty(true);
            return(d);
        }
Esempio n. 5
0
    private static void InitAllWidgets()
    {
        dcList.Clear();
        allWidgetDic.Clear();
        emptyMatList.Clear();

        DrawCallData      data     = null;
        List <UIDrawCall> tempList = new List <UIDrawCall>();

        foreach (var drawcall in UIDrawCall.activeList)
        {
            tempList.Add(drawcall);
        }
        tempList.Sort((a, b) => {
            if (a.manager.depth != b.manager.depth)
            {
                return(a.manager.depth - b.manager.depth);
            }
            if (a.manager.GetInstanceID() != b.manager.GetInstanceID())
            {
                return(a.manager.GetInstanceID() - b.manager.GetInstanceID());
            }
            return(a.depthStart - b.depthStart);
        });
        foreach (var drawcall in tempList)
        {
            var simpleDc = new SimpleDC(false, drawcall);
            dcList.Add(simpleDc);
            if (allWidgetDic.ContainsKey(simpleDc))
            {
                data = allWidgetDic[simpleDc];
            }
            else
            {
                data        = new DrawCallData();
                data.simple = simpleDc;
                allWidgetDic.Add(simpleDc, data);
            }
            foreach (var panel in UIPanel.list)
            {
                if (panel == drawcall.manager)
                {
                    foreach (var widget in panel.widgets)
                    {
                        if (widget.drawCall == drawcall)
                        {
                            if (!data.widgets.Contains(widget))
                            {
                                data.widgets.Add(widget);
                            }
                        }
                        else
                        {
                            if (!emptyMatList.Contains(widget.gameObject))
                            {
                                UITexture tex = widget.GetComponent <UITexture>();
                                UISprite  sp  = widget.GetComponent <UISprite>();
                                UILabel   lb  = widget.GetComponent <UILabel>();

                                /*if ((tex != null || sp != null || lb != null) && widget.drawCall == null)
                                 *
                                 * {
                                 *      emptyMatList.Add(widget.gameObject);
                                 * }*/
                                if (tex != null && tex.mainTexture == null)
                                {
                                    emptyMatList.Add(widget.gameObject);
                                }
                                else if (sp != null && sp.atlas == null)
                                {
                                    emptyMatList.Add(widget.gameObject);
                                }
                                else if (lb != null && lb.text == "")
                                {
                                    emptyMatList.Add(widget.gameObject);
                                }
                                else
                                {
                                    UIWidget    ew  = widget.GetComponent <UIWidget>();
                                    BoxCollider box = widget.GetComponent <BoxCollider>();
                                    if (ew != null && ew.drawCall == null && box != null)
                                    {
                                        emptyMatList.Add(widget.gameObject);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        foreach (var dic in allWidgetDic)
        {
            dic.Value.Sort();
        }
        foreach (var go in emptyMatList)
        {
            var w = go.GetComponent <UIWidget>();
            if (w != null)
            {
                CreateEmptyDC(w);
            }
        }
        dcList.Sort((a, b) => {
            if (a.manager.depth != b.manager.depth)
            {
                return(a.manager.depth - b.manager.depth);
            }
            if (a.manager.GetInstanceID() != b.manager.GetInstanceID())
            {
                return(a.manager.GetInstanceID() - b.manager.GetInstanceID());
            }
            return(allWidgetDic[a].DepthStart - allWidgetDic[b].DepthStart);
        });
    }
Esempio n. 6
0
 private static void CreateEmptyDC(UIWidget w)
 {
     for (int j = 0; j < dcList.Count; j++)
     {
         var  d          = allWidgetDic[dcList[j]];
         bool needCreate = true;
         if (w.panel != d.simple.manager)
         {
             continue;
         }
         if (w.depth <= d.DepthStart)
         {
             if (d.simple.isEmpty)
             {
                 d.AddW(w);
                 return;
             }
             if (needCreate && j > 0)
             {
                 DrawCallData dpre = null;
                 for (int k = j - 1; k >= 0; k--)
                 {
                     if (dcList[k].manager == w.panel)
                     {
                         dpre = allWidgetDic[dcList[k]];
                         break;
                     }
                 }
                 if (dpre != null && dpre.simple.isEmpty)
                 {
                     if (dpre.simple.manager == w.panel)
                     {
                         dpre.AddW(w);
                         return;
                     }
                 }
             }
             CreateEmptyDC(j, w);
             return;
         }
         else
         {
             if (w.depth > d.DepthStart && w.depth < d.DepthEnd)
             {
                 if (d.simple.isEmpty)                    //空
                 {
                     d.AddW(w);
                     return;
                 }
                 else
                 {
                     CreateEmptyDC(j + 1, w);
                     //depth大的 移到后一个新dc中
                     SimpleDC newDC = new SimpleDC(false, d.simple.dc);
                     dcList.Insert(j + 2, newDC);
                     DrawCallData dcData = new DrawCallData();
                     dcData.simple = newDC;
                     allWidgetDic.Add(newDC, dcData);
                     for (int k = 0; k < d.widgets.Count; k++)
                     {
                         UIWidget temp = d.widgets[k];
                         if (temp.depth > w.depth)
                         {
                             dcData.AddW(temp);
                         }
                     }
                     for (int k = 0; k < dcData.widgets.Count; k++)
                     {
                         d.RemoveW(dcData.widgets[k]);
                     }
                     return;
                 }
             }
         }
     }
     CreateEmptyDC(dcList.Count, w);
 }