x


Can I detect whether an item in a list located in an inspector panel has been selected?

I have a list of string items in a generic list inside a ScriptableObject that is editable in design time via an inspector panel.

I would like to display the contents of the currently selected list item in another label on the inspector panel so that the user knows which item in the generic list that they have currently selected.

Some of the inbuilt functionality of the editors are able to detect which items in a generic list the user has selected then open up the relevant inspector panel for editing, so I hope it is able to be done.

Is this possible?

more ▼

asked Jan 15 '10 at 05:04 AM

nathanp812 gravatar image

nathanp812
57 6 6 9

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

You can achieve what you want by making a custom inspector for your scriptable object type. That custom inspector can use its own code to display your generic list of items, and it can also track which one you select, and then provide more information about that item.

For more information about extending the Unity editor:

http://unity3d.com/support/documentation/Components/gui-ExtendingEditor.html

Good luck, Lucas

more ▼

answered Sep 11 '10 at 08:45 PM

Lucas Meijer 1 gravatar image

Lucas Meijer 1 ♦♦
8k 19 43 85

hmm I do not think this answer is enough honestly. I have a similar problem that is knowing which item of a list is selected in the inspection window and surely that page does not help.

Nov 14 '12 at 04:03 PM sebas77
(comments are locked)
10|3000 characters needed characters left

It's hard to tell from your question if you're talking about the built-in Inspector panel, or a panel that you've custom made.

If you're talking about the built-in Inspector panel, you can use the Selection class to access a list of all currently selected GameObjects.

If you're talking about a custom panel you've made, you may have to provide some more details. Specifically, how are you displaying the list of items on the panel, and how do you get the currently selected item elsewhere in your code when you actually do something with it?

more ▼

answered Jan 15 '10 at 05:40 AM

Stelimar gravatar image

Stelimar
3k 14 16 50

Thanks for the reply Stelimar.

I am talking about the built in inspector panel. When viewing an asset file the contents of any ScriptableObject are displayed in the inspector panel.

If the ScriptableObject has a list inside it the list is displayed and you can edit and delete items in the list by resizing the capacity.

I was wanting to detect the selected list item in the child list.

Using Selection.activeObject only seems to give me the parent object. Not the selected child list item of the list that resides under the parent object.

Hopefully that sort of clarifies things.

Jan 15 '10 at 06:03 AM nathanp812
(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:

x3694
x1677
x349

asked: Jan 15 '10 at 05:04 AM

Seen: 1679 times

Last Updated: Nov 14 '12 at 04:04 PM