Ok I find a C# material that does this but can some please convert it to a playmaker action?
using UnityEngine;
public class FindHitSubMesh : MonoBehaviour
{
private int[] subMeshesFaceTotals;
private int totalSubMeshes;
void Awake()
{
MeshFilter mf = (MeshFilter)gameObject.GetComponent(typeof(MeshFilter));
Mesh mesh = mf.mesh;
totalSubMeshes = mesh.subMeshCount;
subMeshesFaceTotals = new int[totalSubMeshes];
for (int i = 0; i < totalSubMeshes; i++)
{
subMeshesFaceTotals[i] = mesh.GetTriangles(i).Length / 3;
}
}
void OnMouseDown()
{
RaycastHit hit;
if (!Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity))
return;
int hitSubMeshNumber = 0;
int maxVal = 0;
for (int i = 0; i < totalSubMeshes; i++)
{
maxVal += subMeshesFaceTotals[i];
if (hit.triangleIndex <= maxVal - 1)
{
hitSubMeshNumber = i + 1;
break;
}
}
Debug.Log("We hit sub mesh number: " + hitSubMeshNumber);
}
}