Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
1
Question by Ony · Sep 25, 2010 at 08:19 PM · assetparentcomponentskinned-mesh

How can I determine the parent of a component?

I need to find out (with Javascript) how to determine the parent object that a Skinned Mesh Renderer component is attached to.

I'm instantiating some character prefabs and the Skinned Mesh Renderer isn't always attached to the same bone in the character heirarchy, so I want to be able to determine which bone object actually contains the Skinned Mesh Renderer.

I can find it no problem with "characterObject.GetComponentInChildren(SkinnedMeshRenderer);" but once I do that I need to know which actual bone in the character contains that component.

Comment
Add comment
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

2 Replies

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

Answer by Jessy · Sep 25, 2010 at 09:20 PM

SkinnedMeshRenderer inherits from Renderer, which inherits from Component. As such, this is easy:

http://unity3d.com/support/documentation/ScriptReference/Component-gameObject.html

At least, I think that's what you're talking about. If you actually want a parent object, and not the Game Object that has the Skinned Mesh Renderer attached, then you can use

http://unity3d.com/support/documentation/ScriptReference/Transform-parent.html

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 Tzan · Sep 25, 2010 at 08:45 PM

So you need the GameObject that holds the Component you can find.

http://unity3d.com/support/documentation/ScriptReference/Component.html

So from Component you can get the transform for the GO.

comp.transform

http://unity3d.com/support/documentation/ScriptReference/Transform.html

From the Transform you can access the entire GO

comp.transform.name // etc

I havent tried it. I'm assuming getting the name of the transform would get you the name of the GO. Maybe comp.name gets you the name of the GO.

Comment
Add comment · Show 4 · 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 Jessy · Sep 25, 2010 at 09:22 PM 0
Share

$$anonymous$$y god, is it really so hard to just try it ins$$anonymous$$d of babbling about whether it works?? :-P

(Yes, it works: http://unity3d.com/support/documentation/ScriptReference/Object-name.html)

avatar image Tzan · Sep 25, 2010 at 09:22 PM 0
Share

While you were babbling about me babbling I was trying it out. :) seems that all .name calls return the GO name. But I'm not entirely sure what he is looking for. I dont do character anim yet. Its best if he reads through those links.

But thanks for the -1 anyway, having a bad day? :)

avatar image Jessy · Sep 25, 2010 at 09:23 PM 0
Share

No, I'm always like this. ;-) Don't post such terrible junk!

avatar image Tzan · Sep 25, 2010 at 09:25 PM 0
Share

It couldnt be all that bad since you agreed that it works :)

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.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

GameObject permanent destruction from "Resources" in EditorWindow 0 Answers

Create GameObjects/Components by Dragging Assets to Hierarchy/Inspector 5 Answers

2D Animation does not start 1 Answer

Adding Script to an "Instantiated" Prefab? 1 Answer

How to clone or re-parent a Component? 4 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