I’m trying to figure out a way to get the graphics raycast to hit the drawn mesh rather than the RectTransform. I want OnPointerClick to trigger when the orange box drawn by OnPopulateMesh is clicked rather than the invisible box. Assuming I’ll have more complicated shapes drawn by OnPopulateMesh, is there an easy way to achieve this? [135675-capture.png*|135675]
public class ClickShape : MaskableGraphic, IPointerClickHandler
{
public void OnPointerClick(PointerEventData eventData){
Debug.Log("Shape Clicked");
}
private Vector3[] allVertices = new Vector3[]{new Vector2(200,200),new Vector2(300,200),new Vector2(300,300),new Vector2(200,300)};
private int[] allTriangles = new int[]{0,1,2,0,2,3};
protected override void OnPopulateMesh(VertexHelper vh){
vh.Clear();
UIVertex vert = new UIVertex();
vert.color = this.color;
foreach(Vector3 vertex in allVertices){
vert.position = vertex;
vert.uv0 = vertex;
vh.AddVert(vert);
}
for(int i = 0; i < allTriangles.Length; i+=3){
vh.AddTriangle(allTriangles*,allTriangles[i+1],allTriangles[i+2]);*
}
}
}
*
,