- Home /
Component on animated object while keeping the prefab
Hey!
I have an animated object (animated in an external program) And on certain parts within this objects hierarchy I would like to add components.
Within the project folder in Unity I cannot see the entire hierarchy.
I can of course just drag the component on the object(in its hierarchy) when its in the scene but then I lose my prefab connection.
so for instance: if the object was a arm and I would like a box collider + script on the hand, what would be the best way of doing this without losing the prefab connection ?
And if that's not possible, would it be possible to make an editor script that adds the required components ? or maybe add the components at runtime ?
Any point in the right direction would be awesome!
thanks a lot!
cheers,
Vin
Answer by TaigaStudios · Jul 06, 2010 at 08:00 PM
Edit what you need and add more components etc and make it a new prefab, and delete old one.
Hey! thanks for the reply. If i make it into a new prefab will it still update if i change the original file in $$anonymous$$aya? so if i add objects to the maya scene does the prefab get updated? thanks!
Tested it out and it doesn't seem to update with the maya file. I guess i'm going to research how to build editor scripts to optimize the workflow. thanks again! Cheers
Answer by microp · Jun 08, 2011 at 03:29 PM
I think this question might contain the answer you're looking for.
As a complement, what I do in this sort of case is to create a public GameObject variable named, for instance, "HandScriptObject", in the parent's script. Into that slot you drag the hand object you want the script attached to. You can then programmatically add the script component to the hand object in Awake(), or instantiate an inspector-exposed prefab and parent it to the hand.
Don't hesitate to experiment with GameObjects! I found out that you can work your way around a lot of problems/limitations by using the right hierarchy setup.
Your answer
![](https://koobas.hobune.stream/wayback/20220613063903im_/https://answers.unity.com/themes/thub/images/avi.jpg)