Skip to main content

How to modify SUIButton target by script using Java

In your Java class, do the following:

public class YourClass extends Component {

// creates a new SpatialObject
public SpatialObject object; // select from Properties

// creates a new STargetRect
public STargetRect type; // select from Properties

// creates a new SUIButton, @AutoWired selects the component from this object
@AutoWired
private SUIButton button;

@Override
public void start() {

}

@Override
public void repeat() {

// changes the type of SUIButton touch area
button.setTargetRectType(type);

// defines the object (a SUI component) which will be the touch area of SUIButton
button.setTargetRectObject(object);
}
}