GameObject _IntersectBone(ref BoneInfo info) { info = null; if (!_hitBones.Any()) { return(null); } var min = _hitBones.Aggregate((result, next) => result.Value < next.Value ? result : next); // Debug.Log("Hit!! = " + min.Key.HeadBone); info = min.Key; return(info.HeadObject); }
public static void DrawBone(this CommandBuffer buf, BoneInfo bone, Material material) { var head = bone.GetHeadPosition(); var tail = bone.GetTailPosition(); var headToTail = tail - head; var distance = headToTail.magnitude; var matrix = Matrix4x4.TRS( head, Quaternion.LookRotation(headToTail, bone.GetUpVector()), new Vector3(distance, distance, distance) ); buf.DrawMesh(SelectedBoneMesh, matrix, material); }