Ejemplo n.º 1
0
        ///<summary>This generates the button UI.  </summary>
        ///<param name="buttonName">The name of the button displayed.  </param>
        ///<param name="parent">The parent transform of the button.  </param>
        ///<param name="action">The action that the button triggers onclick.  </param>
        ///<returns>Returns the button gameObject.  </returns>
        protected virtual GameObject CreateUIButton(string buttonName, Transform parent, UnityAction action)
        {
            var cellBuilder = new CellBuilder(buttonName);

            cellBuilder.SetFont(_font);
            cellBuilder.SetBackgroundImage(_hasActivitiesBackground, 0f);
            cellBuilder.SetLayoutElement(_preferredHeight, _preferredWidth);
            cellBuilder.SetParent(parent);

            DongerUI.CellBuilderHandler cellBuilderHandler = cellBuilder.ApplyFont;
            cellBuilderHandler += cellBuilder.ApplyBackgroundImage;
            cellBuilderHandler += cellBuilder.ApplyParent;
            cellBuilderHandler += cellBuilder.ApplyLayoutElement;

            var button     = new ButtonCellDongerUI(buttonName, action, cellBuilderHandler);
            var buttonCell = new CellUI(button);

            return(buttonCell.Build());
        }
Ejemplo n.º 2
0
        ///<summary>Builds UI the cell.  </summary>
        ///<param name="cellName">The name of the cell.  </param>
        ///<param name="parent">The parent the cell resides under.  </param>
        protected virtual GameObject BuildCell(string cellName, Transform parent, Texture2D background, TextAnchor _textAnchor)
        {
            var cellBuilder = new CellBuilder(cellName);

            cellBuilder.SetFont(_font);
            cellBuilder.SetParent(parent);
            cellBuilder.SetTextAnchor(_titleTextAnchor);
            cellBuilder.SetLayoutElement(_preferredHeight, _preferredWidth);
            cellBuilder.SetBackgroundImage(background, _opacity);
            cellBuilder.SetAnchors(new Vector2(0, 0), new Vector2(1, 1));

            DongerUI.CellBuilderHandler cellBuilderHandler = cellBuilder.ApplyFont;
            cellBuilderHandler += cellBuilder.ApplyParent;
            cellBuilderHandler += cellBuilder.ApplyAnchors;
            cellBuilderHandler += cellBuilder.ApplyLayoutElement;
            cellBuilderHandler += cellBuilder.ApplyBackgroundImage;

            var textCell = new TextCellDongerUI(cellName, cellBuilderHandler);
            var cell     = new CellUI(textCell);

            return(cell.Build());
        }