It looks like I’d have to replicate the Rectangle class (modify the _localDraw method) to achieve what I want, or just make the default rectangle 100% transparent and use images for the button states, but either way I guess the mouse over hit target will still be a rectangle right?
I’m also having a bit of success with the second of my options. I created a Shape.ts extending the standard GUI Rectangle.ts then created a new draw method for the shapes I need:
const stepArrowLength = height / 2 / 2;
context.beginPath();
switch(this._shape) {
case Shape.STEP_ARROW_FIRST: {
context.moveTo(x, y);
context.lineTo(x + width - stepArrowLength, y);
context.lineTo(x + width, y + (height / 2));
context.lineTo(x + width - stepArrowLength, y + height);
context.lineTo(x, y + height);
context.lineTo(x, y);
break;
}
case Shape.STEP_ARROW_MIDDLE: {
context.moveTo(x, y);
context.lineTo(x + width - stepArrowLength, y);
context.lineTo(x + width, y + (height / 2));
context.lineTo(x + width - stepArrowLength, y + height);
context.lineTo(x, y + height);
context.lineTo(x + stepArrowLength, y + (height / 2));
context.lineTo(x, y);
break;
}
case Shape.STEP_ARROW_LAST: {
context.moveTo(x, y);
context.lineTo(x + width, y);
context.lineTo(x + width, y + height);
context.lineTo(x, y + height);
context.lineTo(x + stepArrowLength, y + (height / 2));
context.lineTo(x, y);
break;
}
}
context.closePath();
Then I make a new ShapeButton.ts extending Shape which is essentially a duplicate of the inbuilt Button class.
I’m not sure how to show this in a PG, so I might just post the code here when complete.
Here’s a screenshot of the STEP_ARROW_MIDDLE shape:
Is it possible to make an Image follow a mesh in any way? Like a rectangle does using linkWithMesh API? I have checked the playground by @aWeirdo but I want an image to follow a mesh. Thanks in advance.
Sorry for the late reply. Actually I wanted to create a triangle in the GUI but I was not able to do so. So I changed my approach to adding an image. But after spending some more time I was able to create a triangle by extending the Rectangle. Here’s a very basic playground of the same : https://playground.babylonjs.com/#NTZ766#5