Editor.Components.ScreenTransformConstraints
ClassUsed with Editor.Components.ScreenTransformConstraints.
Index
Example
// ScreenTransformConstraints control how a ScreenTransform reacts to
// its parent's size changes — fix one axis or pin to specific edges.
// Common pattern: keep a HUD button at fixed pixel size, pinned to the
// top-right of the screen so it stays put when the canvas resizes.
const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
const scene = model.project.scene;
const canvasObj = scene.createSceneObject('UICanvas');
canvasObj.addComponent('Canvas');
const buttonObj = scene.createSceneObject('PinnedButton');
buttonObj.setParent(canvasObj);
const st = buttonObj.addComponent('ScreenTransform') as Editor.Components.ScreenTransform;
st.constraints.fixedWidth = true; // keep width regardless of parent size
st.constraints.fixedHeight = true; // keep height regardless of parent size
st.constraints.pinToTop = true; // anchor to top edge
st.constraints.pinToRight = true; // anchor to right edge
console.log('ScreenTransform pinned to top-right with fixed dimensions');
Constructors
Constructor
new ScreenTransformConstraints():
ScreenTransformConstraints
Instantiate a screen transform constraints object for UI element positioning rules.
Returns
ScreenTransformConstraints
Properties
fixedHeight
fixedHeight:
boolean
Lock the screen transform height in place.
fixedWidth
fixedWidth:
boolean
Lock the screen transform width in place.
pinToBottom
pinToBottom:
boolean
Anchor the screen transform to the bottom edge.
pinToLeft
pinToLeft:
boolean
Anchor the screen transform to the left edge.
pinToRight
pinToRight:
boolean
Anchor the screen transform to the right edge.
pinToTop
pinToTop:
boolean
Anchor the screen transform to the top edge.