Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by ExciteMike · Oct 31, 2010 at 03:49 PM · guiarrayinspector

array inspector reordering

My component has an array property for an ordered list of other GameObjects that it will work with. When I need to change the order of those game objects, it's a bit of a pain. In the worst case, moving the last one to the first slot, I need to reset every single element. Is there some other way of doing it? It'd be slick if I could drag elements around in the list, but that doesn't seem to work.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image duke · Jan 15, 2013 at 12:37 PM 0
Share

i never understood why they didn't replicate the Script Execution Order editor for arrays in the inspector. DragDrop reordering thanks!

8 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Jesse Anders · Oct 31, 2010 at 04:33 PM

You might try using a List instead. IIRC, the inspector interface for List reflects that its interface is substantially different from that of an array (for example, I believe you can delete items in the list freely without affecting the values of other items). This still won't allow you to drag items around as you describe, but it might be an improvement over what you have currently.

Another option might be to create a custom inspector or editor window that facilitated whatever operations you might need to perform. For example, you could create an editor window where you can select items in the list and then click 'up' or 'down' buttons to move them up or down in the list. (I've used this method myself, and it worked fine.)

Maybe someone else will be able to off a better suggestion though.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jessy · Oct 31, 2010 at 05:31 PM 0
Share

$$anonymous$$y suggestion is to request it. http://feedback.unity3d.com/

avatar image ExciteMike · Oct 31, 2010 at 08:35 PM 0
Share

List seemed to do the same thing as an array, but it turned out it wasn't a big deal to write a custom editor for this one case. It came out looking like this: http://www.pasteit4me.com/1473001

I don't suppose it's possible to do make Unity use a custom editor on all arrays all over the place, is it?

avatar image Adsy · Jan 31, 2012 at 10:26 PM 0
Share

Hey Jesse Anders, I know this post is quite old, but I've been trying to do this exact thing for days now and can't figure it out. Your solution is exactly what I've been trying to do. You mention you've done it with the buttons for up and down before. How did you get which item is selected? or how did you display the array contents for that matter?

avatar image sebas77 · Nov 13, 2012 at 02:49 PM 1
Share

@Excite$$anonymous$$ike do you still have that code?

avatar image ExciteMike · Nov 13, 2012 at 03:49 PM 0
Share

I'm pretty sure I still have it... but I can't remember which project I was working on at the time, which makes it really hard to find :/

avatar image
23

Answer by numberkruncher · Oct 03, 2013 at 11:50 PM

I have created a custom control which does allow items to be rearranged using drag and drop:

Reorderable List Editor Field for Unity:

https://bitbucket.org/rotorz/reorderable-list-editor-field-for-unity

Screenshot:

alt text


screenshot.png (13.3 kB)
Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Michael-Ryan · Oct 04, 2013 at 01:02 AM 2
Share

Very cool! I'd vote that up, but I have no reputation. :\

avatar image Tortuap · Mar 08, 2014 at 11:42 AM 1
Share

I use that one too. Best solution I've found. Need to create a custom inspector, but it's worth that small effort.

avatar image Julian-Glenn · Mar 25, 2014 at 02:34 AM 0
Share

great stuff :-)

avatar image tangwentian · Jul 05, 2017 at 11:02 AM 0
Share

Cool! I like it.

avatar image
7

Answer by Michael-Ryan · Dec 09, 2011 at 04:32 PM

While there is no easy way to move elements around, you are able to duplicate existing array items and remove elements from the array using some shortcut keys.

From the Unify Community wiki:

Builtin arrays are the only reasonable way to allow artists and level designers to define lists of things without touching code or making your own editor extensions. However, editing long arrays can get tedious if you are relying on things being in a certain order and you need to make changes later.

There are two undocumented functions you can use when editing arrays:

Command-Delete (Ctrl-Backspace on Windows): Remove the selected element in an array. The element will be deleted, the array length will be reduced by one and subsequent elements will each have their indices reduced by one.

Command-D (Ctrl-D on Windows): Duplicate the selected element. The element will be duplicated, with the duplicate inserted after the selected element. The array length will be increased by one, and all subsequent elements will have their indices increased by one.

I have no idea why these functions are undocumented and only available via shortcut, but they can save your day when you realize that element 4 in an array of length 50 shouldn't be there.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
3

Answer by Zogg · Dec 18, 2011 at 09:43 PM

Actually, Ctrl-D works on Windows, but Ctrl-Backspace doesn't.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Michael-Ryan · Dec 18, 2011 at 10:27 PM 0
Share

Does Ctrl-Delete work on Windows?

avatar image centaurianmudpig · Jan 14, 2012 at 04:40 PM 1
Share

Use Shift-Delete to delete on Windows (Using 3.5 beta).

avatar image KainAsylum · Aug 15, 2013 at 02:23 PM 1
Share

On windows, you can simply press the 'Delete' key ins$$anonymous$$d of Ctrl-Backspace :)

avatar image
1

Answer by Eric5h5 · Oct 31, 2010 at 05:16 PM

As far as moving the last one to the first slot, you can duplicate the first slot, change the value of the duplicate, and delete the last slot. You don't need a List for that; it works fine with an array.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Waz · Jun 02, 2011 at 01:09 AM 0
Share

Depends how simple the "value" is. I have arrays of big complicated structs, and they're nested (so CustomEditor can't really help). Time to write the array reordering window suggested above.

avatar image Waz · Jun 02, 2011 at 02:22 AM 0
Share

Ugh. Done, but it's so ugly, and SerializedProperty is so under-documented and full of gotchas, that I'm not going to post it anywhere.

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to show an array of custom objects in Inspector? 2 Answers

GUI, Inspector has no control for Arrays? 3 Answers

Public Array with a class not showing in Inspcetor 1 Answer

IndexOurOfRange: Array index out of range. 0 Answers

Array elements are empty in the inspector? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges