- Home /
link that point to objects
i am trying to build hierarchy from object that has a lot of subobjects in a way that i get this displayed:
"main object > object1 > subobject2"
where all parts act as links, when clicked that object gets selected. how to do that?
to additionaly explain:
i know how to build hierarchy in the editor. just stack one object on top another. that is not the problem.i know how to loop through the object and get children, so if i select one of the children i get label on the screen something like this: main object > sub object > object (object that is selected).. i know how to do all of this. i would like to make the objects in the label clickable, so when clicked the current camera target changes to clicked object.
maybe to have array of buttons where titles of the buttons would be the objects and when button clicked it will select the object...
can it be done like this?
Do you mean that you click on one object and then another object gets selected? That's not possible in Unity.
Answer by jashan · Aug 16, 2010 at 11:11 AM
If I understand your question correctly (see my comment), then there's bad news because Unity doesn't support "links". So, clicking on one object in the hierarchy and selecting another one is not possible. Creating a hierarchy of objects, on the other hand, is trivial (just drag'n'drop the objects one below the other).
Also, you could write an editor script that adds a button to your "hierarchy objects" which then selects the "original objects". So, you'd have scripts attached to those "hierarchy objects" which have a "slot" for the linked object. That would be trivial:
public class HierarchyObject : MonoBehaviour {
public Transform linkedObject;
}
The editor script would be a bit more complex ... let me know if that's what you need and I can extend the answer with it ... basically, what you'd get is this:
Click on the object in your hierarchy to select. Click on button in property inspector (the button comes from the editor script) to select "original object".
I'm not perfectly sure that it'll work but almost perfectly sure ;-)
;-)
i dont need editor script, i just want to simulate links, and i got this idea to do it with buttons. so when i select object in the game, i get its hierarchy path (i dont know how to do this yet) and then i make buttons that selects objects in the path when clicked
Your answer
