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?
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:
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 ;-)
answered Aug 16 '10 at 11:11 AM