The use of some components of UGUI in unity

一、Toggle Group(Script)

Add the Toggle Group component to LeftButtons, and check the property Allow Switch Off, which means that the property Is On with the Toggle component on all its children is off.

So far, a button group ToggleGroup has been created, and only one Toggle under this group can be selected.

2. Grid Layout Group components

1. Padding: RectOffset type, rectangle offset, for details, please poke the introduction of the Horizontal Layout Group component of UGUI

2. Cell Size: Vector2 type, the default value is (100,100), the size of each cell in the grid

[SerializeField] protected Vector2 m_CellSize = new Vector2(100, 100);
public Vector2 cellSize { get { return m_CellSize; } set { SetProperty(ref m_CellSize, value); } }

3. Spacing: Spacing here is different from horizontal layout and vertical layout. It is of Vector2 type. Since it is a grid layout, of course, there are horizontal and vertical intervals. I will not introduce too much here.

4. Start Corner: Corner enumeration type

public enum Corner 
{
    UpperLeft = 0 ,       // upper left corner 
    UpperRight = 1 ,      // upper right corner 
    LowerLeft = 2 ,       // lower left corner 
    LowerRight = 3       // lower right corner 
}

 Which corner should the first cell be placed in, the default is the upper left corner of the UpperLeft

 5. Start Axis: Axis enumeration type

public enum Axis 
{
    Horizontal = 0 ,      // horizontal 
    Vertical = 1         // vertical 
}

(1) Horizontal: Horizontally
prioritizes the horizontal arrangement of cells
(2) Vertical: Vertically
prioritizes the vertical arrangement of cells

6. Child Alignment: TextAnchor enumeration type, text anchor, for details, please poke the introduction of the Horizontal Layout Group component of UGUI

7. Constraint: Constraint enumeration type

public enum Constraint 
{
    Flexible = 0 ,               // Do not limit the number of rows and columns 
    FixedColumnCount = 1 ,       // Constrain the specified number of columns 
    FixedRowCount = 2           // Constrain the specified number of rows 
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325046140&siteId=291194637