Skip to main content

SUIRect

SUIRect

What is a SUIRect for?​

  • SUIRect is responsible for storing the size, margin, padding, and other properties of an interface element.


Size​

  • The width and height of the element.

Example​

package JAVARuntime;

public class YourClass extends Component {

private SUIRect rect;
public SUnitType type; // select in properties

public int width = 100;
public int height = 100;

@Override
public void start() {

// find the component
rect = myObject.findComponent("SUIRect");

}

@Override
public void repeat() {

// to modify width/height of SUIRect
rect.setInt("Width", width);
rect.setInt("Height"), height);

// to modify the types of width/height units
rect.setUnit("Width", type);
rect.setUnit("Height", type);

}

}

Margin​

  • The margin area on the four sides of the element.

Example​

package JAVARuntime;

public class YourClass extends Component {

private SUIRect rect;
public SUnitType type; // select in properties

public int leftMargin = 100;
public int topMargin = 100;
public int rightMargin = 100;
public int bottonMargin = 100;

@Override
public void start() {

// find the component
rect = myObject.findComponent("SUIRect");

}

@Override
public void repeat() {

// to modify the margin leftMargin/topMargin/rightMargin/bottonMargin of SUIRect
rect.setInt("LeftMargin", leftMargin);
rect.setInt("TopMargin", topMargin);
rect.setInt("RightMargin"), rightMargin);
rect.setInt("BottomMargin", bottomMargin);

// to modify the types of margin units
rect.setUnit("LeftMargin", type);
rect.setUnit("TopMargin", type);
rect.setUnit("RightMargin", type);
rect.setUnit("BottomMargin", type);

}

}

Padding​

  • The internal distance between the element's contents and its edges.

Example​

package JAVARuntime;

public class YourClass extends Component {

private SUIRect rect;
public SUnitType type; // select in properties

public int leftPadding = 100;
public int topPadding = 100;
public int rightPadding = 100;
public int bottonPadding = 100;

@Override
public void start() {

// find the component
rect = myObject.findComponent("SUIRect");

}

@Override
public void repeat() {

// to modify the padding leftPadding/topPadding/rightPadding/bottonPadding of SUIRect
rect.setInt("LeftPadding", leftPadding);
rect.setInt("TopPadding", topPadding);
rect.setInt("RightPadding"), rightPadding);
rect.setInt("BottomPadding", bottomPadding);

// to modify the types of padding units
rect.setUnit("LeftPadding", type);
rect.setUnit("TopPadding", type);
rect.setUnit("RightPadding", type);
rect.setUnit("BottomPadding", type);

}

}

Anchors​

  • They are anchors that attach elements to each other.

Example​

package JAVARuntime;

public class YourClass extends Component {

private SUIRect rect;

public SHorizontalConstraintTarget leftConstraint; // select in properties
public SVerticalConstraintTarget topConstraint; // select in properties
public SHorizontalConstraintTarget rightConstraint; // select in properties
public SVerticalConstraintTarget bottonConstraint; // select in properties

@Override
public void start() {

// find the component
rect = myObject.findComponent("SUIRect");

}

@Override
public void repeat() {

// to modify the anchors type
rect.setHorizontalAnchorType("LeftConstraint", leftConstraint);
rect.setVerticalAnchorType("TopConstraint", topConstraint);
rect.setHorizontalAnchorType("RightConstraint", rightConstraint);
rect.setVerticalAnchorType("BottomConstraint", bottomConstraint);

}

}

Rotation​

  • The X, Y, and Z rotation of the element.

Example​

package JAVARuntime;

public class YourClass extends Component {

private SUIRect rect;

private Quaternion rot = new Quaternion();
private Vector3 vec3 = new Vector3(0, 0, 45);

@Override
public void start() {

// find the component
rect = myObject.findComponent("SUIRect");

// to convert the value of [Vector3] to the values of [Quaternion]
rot.setFromEuler(vec3);

}

@Override
public void repeat() {

// to modify the rotation
rect.setRotation(rot);

}

}

Layers​

  • The layer of the element in relation to other elements on the canvas.

Example​

package JAVARuntime;

public class YourClass extends Component {

private SUIRect rect;

@Override
public void start() {

// find the component
rect = myObject.findComponent("SUIRect");

}

@Override
public void repeat() {

// to modify the layer
rect.setLayer(2);

}

}