I would like to have a way to draw the bones of my Skinned Meshes to the screen. Is there something in the asset store, a tutorial, or a simple way of doing this? I have searched and can’t seem to find a solution.
Here’s a small script that should draw a line between all bones inside the editor. I wrote this from scratch. I haven’t tested it but it should work.
// DrawBones.cs
using UnityEngine;
public class DrawBones : MonoBehaviour
{
private SkinnedMeshRenderer m_Renderer;
void Start()
{
m_Renderer = GetComponentInChildren<SkinnedMeshRenderer>();
if (m_Renderer == null)
{
Debug.LogWarning("No SkinnedMeshRenderer found, script removed");
Destroy(this);
}
}
void LateUpdate()
{
var bones = m_Renderer.bones;
foreach(var B in bones)
{
if (B.parent == null)
continue;
Debug.DrawLine(B.position, B.parent.position, Color.red);
}
}
}
Actually, I just came up with an idea. Instead of drawing bones, I guess we could draw a sprite where the joint is. This will actually probably be better for the tech illiterate, which is who we are sort of targeting.