BoneDebug

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<csharp>" to "<syntaxhighlight lang="csharp">")
m (Text replace - "</csharp>" to "</syntaxhighlight>")
 
Line 36: Line 36:
 
     }
 
     }
 
  }
 
  }
</csharp>
+
</syntaxhighlight>

Latest revision as of 20:44, 10 January 2012

Author: Jesper Taxbøl

[edit] Description

This is a simple C# script I am using when debugging animations.

It allows you to see the bones of a character, revealing details that can be hard to see through skinning.

 using UnityEngine;
 using System.Collections;
 [ExecuteInEditMode]
 public class BoneDebug : MonoBehaviour
 {
    void drawbone(Transform t)
    {
        foreach (Transform child in t)
        {
            float len = 0.05f;
            Vector3 loxalX = new Vector3(len, 0, 0);
            Vector3 loxalY = new Vector3(0, len, 0);
            Vector3 loxalZ = new Vector3(0, 0, len);
            loxalX = child.rotation * loxalX;
            loxalY = child.rotation * loxalY;
            loxalZ = child.rotation * loxalZ;
            Debug.DrawLine(t.position * 0.1f + child.position * 0.9f, t.position * 0.9f + child.position * 0.1f, Color.white);
            Debug.DrawLine(child.position, child.position + loxalX, Color.red);
            Debug.DrawLine(child.position, child.position + loxalY, Color.green);
            Debug.DrawLine(child.position, child.position + loxalZ, Color.blue);
            drawbone(child);
        }
    }
    void Update()
    {
        drawbone(transform);
    }
 }
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox