UI Widgets: CheckBox, RadioButton, RadioGroup, DrivingWheel
Este topico mostra como usar os novos widgets de UI no editor e em Java.
Create in the Editor
- Topbar -> Create Object -> UI -> Widgets -> Check box
- Topbar -> Create Object -> UI -> Widgets -> Radio group
- Topbar -> Create Object -> UI -> Widgets -> Driving wheel
The Radio group instantiator creates a UIRadioGroup with a UIVerticalLayout and two UIRadioButton children.
Theme Images
O tema padrao fornece as texturas de checkbox e radio. Voce pode trocar as imagens do tema ou substituir as texturas por componente no inspetor ou via codigo.
Java Usage
UICheckBox
SpatialObject myObject = /* your object */;
UICheckBox comp = myObject.findComponent(UICheckBox.class);
if (comp != null) {
Texture tex = /* load texture */ null;
// set the checked value:
comp.checked = true;
// read the checked value:
boolean checkedValue = comp.checked;
// read the pressed value:
boolean pressedValue = comp.pressed;
// read the down value:
boolean downValue = comp.down;
// read the up value:
boolean upValue = comp.up;
// set the color value:
comp.color = new Color(255, 255, 255, 255);
// read the color value:
Color colorValue = comp.color;
// set the checkedTexture value:
comp.checkedTexture = tex;
// read the checkedTexture value:
Texture checkedTextureValue = comp.checkedTexture;
// set the uncheckedTexture value:
comp.uncheckedTexture = tex;
// read the uncheckedTexture value:
Texture uncheckedTextureValue = comp.uncheckedTexture;
}
UIRadioGroup
SpatialObject myObject = /* your object */;
UIRadioGroup comp = myObject.findComponent(UIRadioGroup.class);
if (comp != null) {
}
UIRadioButton
SpatialObject myObject = /* your object */;
UIRadioButton comp = myObject.findComponent(UIRadioButton.class);
if (comp != null) {
Texture tex = /* load texture */ null;
// set the checked value:
comp.checked = true;
// read the checked value:
boolean checkedValue = comp.checked;
// read the pressed value:
boolean pressedValue = comp.pressed;
// read the down value:
boolean downValue = comp.down;
// read the up value:
boolean upValue = comp.up;
// set the color value:
comp.color = new Color(255, 255, 255, 255);
// read the color value:
Color colorValue = comp.color;
// set the checkedTexture value:
comp.checkedTexture = tex;
// read the checkedTexture value:
Texture checkedTextureValue = comp.checkedTexture;
// set the uncheckedTexture value:
comp.uncheckedTexture = tex;
// read the uncheckedTexture value:
Texture uncheckedTextureValue = comp.uncheckedTexture;
}
UIDrivingWheel
SpatialObject myObject = /* your object */;
UIDrivingWheel comp = myObject.findComponent(UIDrivingWheel.class);
if (comp != null) {
Texture tex = /* load texture */ null;
// read the value value:
float valueValue = comp.value;
// read the angle value:
float angleValue = comp.angle;
// set the lerp value:
comp.lerp = 1f;
// read the lerp value:
float lerpValue = comp.lerp;
// set the maxAngle value:
comp.maxAngle = 1f;
// read the maxAngle value:
float maxAngleValue = comp.maxAngle;
// read the pressed value:
boolean pressedValue = comp.pressed;
// read the down value:
boolean downValue = comp.down;
// read the up value:
boolean upValue = comp.up;
// set the color value:
comp.color = new Color(255, 255, 255, 255);
// read the color value:
Color colorValue = comp.color;
// set the texture value:
comp.texture = tex;
// read the texture value:
Texture textureValue = comp.texture;
}
Tips
- The checkbox toggles on
downto avoid the first-frameupevent. UIDrivingWheeluses touch input to set a continuous axis value.