• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by DoctorWhy · Oct 09, 2012 at 08:18 PM · animationbonesdrawvisible

Make bones visible when playing

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.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Oct 09, 2012 at 10:14 PM 0
Share

For what purpose do you want to display the bones? Do you want to display them in the editor only or in a build? When you want to display them in the editor for debugging purposes you can use Debug.DrawLine().

If you want to view them in a build it's probably easier to "model" them as mesh. Bones are not like real bones, they are just Transforms in a hierarchically setup.

I can post an example for the first case...

avatar image DoctorWhy · Oct 09, 2012 at 10:28 PM 0
Share

We want to display the bones during runtime. We allow users to manipulate the bones, which is already done. But, I can't figure out how to draw them. The problem with modeling them out is the fact that we are not the ones creating the models, and there will be quite a lot.

Actually, I just came up with an idea. Ins$$anonymous$$d 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.

Thanks for the help though, it really got me thinking.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by DoctorWhy · Oct 09, 2012 at 10:28 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Bunny83 · Oct 09, 2012 at 10:24 PM

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);
         }
     }
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image skullthug · Oct 04, 2013 at 05:21 AM 0
Share

This is awesome! Thank you for posting this.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Animation switching but rotation isn't proper! 0 Answers

Activating One Part of An Animation 2 Answers

Animating bones and the entire skeleton together 0 Answers

Can I make animations snap to a frame? 1 Answer

Clothing as seperate objects, but using player bones. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges