x


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?

more ▼

asked Aug 16 '10 at 10:38 AM

pretender gravatar image

pretender
497 121 134 145

Do you mean that you click on one object and then another object gets selected? That's not possible in Unity.

Aug 16 '10 at 11:07 AM jashan
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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 ;-)

;-)

more ▼

answered Aug 16 '10 at 11:11 AM

jashan gravatar image

jashan
10.1k 25 40 116

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

Aug 16 '10 at 08:36 PM pretender
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x147
x73
x53

asked: Aug 16 '10 at 10:38 AM

Seen: 1263 times

Last Updated: Aug 16 '10 at 12:14 PM