BoneDebug

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m
Line 1: Line 1:
 +
Author: [[User:Tax| Jesper Taxbøl]]
 +
 +
== Description ==
 +
 
This is a simple C# script I am using when debugging animations.  
 
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.
 
It allows you to see the bones of a character, revealing details that can be hard to see through skinning.
  
 
+
<csharp>
 
  using UnityEngine;
 
  using UnityEngine;
 
  using System.Collections;
 
  using System.Collections;
Line 32: Line 36:
 
     }
 
     }
 
  }
 
  }
 
+
</csharp>
 
+
Author: [http://www.unifycommunity.com/wiki/index.php?title=User:Tax Jesper Taxbøl]
+

Revision as of 16:50, 20 September 2011

Author: Jesper Taxbøl

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.

<csharp>

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);
   }
}

</csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox