How do I get a prefab to load an object that is in the hierarchy, into it’s transform node?
I guess I could make it do a search for the object. but that is slow I’ve been told.
How do I get a prefab to load an object that is in the hierarchy, into it’s transform node?
I guess I could make it do a search for the object. but that is slow I’ve been told.
If I understand your problem correctly I believe you could do it with transform.Find http://unity3d.com/support/documentation/ScriptReference/Transform.Find.html . Notice how you can search down the hierarchy by using “/”. I agree in the fact that this is a slow function. However, there is nothing bad about calling this once in your Awake function and storing the link in a local variable so you can access the object once more during the update.
private Transform aTransform;
void Awake()
{
aTransform = this.transform.Find("ObjectToLookFor/DownTheHierarchy/EvenFurtherDown");
}
void Update()
{
// Now I can use aTransform as many times as I want without incurring the "Find" performance cost.
}
I hope this answers the question.
Cheers,