Beispiel #1
0
    private void RefreshLabelRow()
    {
        if (!CanvasMgr.Instance.IsRefreshCanvas())
        {
            if (isRefreshLabelRow)
            {
                isRefreshLabelRow = false;
            }
            return;
        }
        if (!isRefreshLabelRow)
        {
            return;
        }

        for (int i = 0; i < lLabelRows.Count; i++)
        {
            RowLabelMgr row    = lLabelRows[i];
            float       rowW   = (row.transform as RectTransform).sizeDelta.x; // row's width
            float       panelW = rt.sizeDelta.x;                               // panel's width

            // if cont's width > panel's width
            if (rowW > panelW)
            {
                // extend cont's width
                if (rowW <= panelZoneW)
                {
                    rt.sizeDelta = new Vector2(rowW, rt.sizeDelta.y);
                }
                // retrieve last label of current row && add as first element to next row
                else
                {
                    if (panelW < panelZoneW)
                    {
                        rt.sizeDelta = new Vector2(panelZoneW, rt.sizeDelta.y);
                    }

                    if (row.ChildCount() > 1)
                    {
                        Label lastLabel = row.RetrieveLastLabel();

                        // add label as first element of next row
                        RowLabelMgr nextRow = null;
                        if (i + 1 == lLabelRows.Count)
                        {
                            nextRow = AddLabelRow();
                        }
                        else
                        {
                            nextRow = lLabelRows[i + 1];
                        }
                        nextRow.AddLabelAsFirst(lastLabel);

                        lastLabel.transform.parent = nextRow.transform;
                    }
                }
            }
        }
    }
Beispiel #2
0
    // ========================================= PRIVATE FUNCS =========================================
    private RowLabelMgr AddLabelRow()
    {
        if (prefRowLabel)
        {
            RowLabelMgr rowLabel = Instantiate(prefRowLabel, transLabelCont).GetComponent <RowLabelMgr>();
            rowLabel.Init(this);

            // store label cont
            lLabelRows.Add(rowLabel);
            return(rowLabel);
        }

        return(null);
    }
Beispiel #3
0
    public void AddLinkLabel(string referPanelKey)
    {
        // add new row if empty
        if (lLabelRows.Count == 0)
        {
            AddLabelRow();
        }

        if (lLabelRows.Count > 0)
        {
            // append label to last row
            RowLabelMgr rowLabel = lLabelRows[lLabelRows.Count - 1];
            if (rowLabel)
            {
                rowLabel.AddLinkLabel(referPanelKey);     // add linking panel

                OnChildLabelEditDone();
                CanvasMgr.Instance.RefreshCanvas();
            }
        }
    }
Beispiel #4
0
    public void AddInputLabel(string labelTitle = "")
    {
        // add new row if empty
        if (lLabelRows.Count == 0)
        {
            AddLabelRow();
        }

        if (lLabelRows.Count > 0)
        {
            // append label to last row
            RowLabelMgr rowLabel = lLabelRows[lLabelRows.Count - 1];
            if (rowLabel)
            {
                // add input panel
                rowLabel.AddInputLabel(labelTitle);

                OnChildLabelEditDone();
                CanvasMgr.Instance.RefreshCanvas();
            }
        }
    }