///<summary> Create a row for each game object. </summary> ///<param name="parent">The parent that the the row will be childred to. </param> ///<returns>Returns a Row Game Object. </returns> protected virtual GameObject CreateUIRow(string rowName, Transform parent = null) { var cellBuilder = new CellBuilder("Row"); cellBuilder.SetLayoutElement(_preferredHeight, _preferredWidth); cellBuilder.SetHorizontalLayoutGroup(false, _spacing, true); cellBuilder.SetParent(parent); DongerUI.CellBuilderHandler cellBuilderHander = cellBuilder.ApplyLayoutElement; cellBuilderHander += cellBuilder.ApplyHorizontalLayoutGroup; cellBuilderHander += cellBuilder.ApplyParent; var cell = new RowCellDongerUI(rowName, cellBuilderHander); return(cell.Build()); }
///<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()); }
///<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()); }