Search Unity

[RELEASED] [v1.5] Reorderable Arrays in Inspector - available in Asset Store

Discussion in 'Assets and Asset Store' started by TheGering, Sep 21, 2016.

  1. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Hello Everyone!

    After some work, improving and bug fixing I decided to release my Editor Extensions to the Asset Store. :cool:

    This editor extension will improve your workflow with arrays in the inspector. It works out of the box and can even be used with custom inspectors. It replaces the default inspector arrays with a reorderable version. As soon as you install the Asset into your project, all inspector arrays will upgrade. I hope you like this editor extension and it will save you time. :)

    Info: It also supports drag'n'drop and other features like the default arrays. If you have an array property which you wouldn't like to be reorderable, you could simply give it the attribute [NotReorderable].

    User Guide: ReorderableArrays.pdf

    Feedback: I would love to hear your feedback and feature requests!

    Screen Shot 2016-09-21 at 09.23.33.png

    History:
    Version 1.5 (12/10/2016)
    bugfix NullReferenceException
    Version 1.4 (11/30/2016) bugfix with nested reorderable arrays
    Version 1.3 (10/18/2016) nested reorderable arrays
    Version 1.2 (09/26/2016) null pointer bug fix
    Version 1.1 (09/20/2016) some improvements
    Version 1.0 (09/14/2016) first release
     
    Last edited: Dec 16, 2016
  2. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    I wanted to mention that projects that use a custom editor which uses the attribute like this:
    Code (CSharp):
    1. [CustomEditor(typeof(MonoBehaviour), true, isFallback = true)]
    will interfere with ReorderableArrayEditor. This will have the effect, that arrays appear as always and not reorderable. To resolve this issue, simply change your custom editor to extend ReorderableArrayEditor.

    Example:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. [CustomEditor(typeof(MonoBehaviour), true, isFallback = true)]
    5. [CanEditMultipleObjects]
    6. public class CustomEditorTest : ReorderableArrayEditor {
    7.  
    8.     public override void OnInspectorGUI() {
    9.         DrawDefaultInspector();
    10.     }
    11. }
    12.  
    See this document to get more info and a coding reference.
     
  3. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Version 1.2 just released: fixes some bugs with null pointer exceptions.
     
  4. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Version 1.3 just released:
    • nested arrays: enable nested reorderable arrays via menu
     
  5. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Version 1.4 just released:
    • fixed a bug, when nested arrays were enabled
    • package has been submitted using Unity 5.3.0, and 5.4.2 to improve compatibility within the range of these versions of Unity.
     
  6. Fronne

    Fronne

    Joined:
    Sep 25, 2014
    Posts:
    112
    Hi Robert,

    It doesn't work properly in Unity 5.5.0f3, it works at start but after hitting da Play Button or changing a Scene the Party is Over. When restarting Unity again it works again until Play is pressed or the Scene is changed...

    Not a big problem for me because I want to use it only to change the order of some some fields in scrollers every now and then so I deleted your Asset and can Import it when I need it but this is not how it's ment to be...

    In my case I just need a way to change the order of some scroller "fields" fast...
    I used Advanced Inspector in the past but that Asset is OverKill and not always Up to Date with a new Unity Release...
    I use the TextAreaAttribute because the fields are different in size and I want to see it compact in the inspector...

    [TextArea(1,16)]
    public string[] scrollerText;


    I bought your Asset because the price is close to zero but would never bought it for more because of the dll file...
    Why don't you release it as full source, we can change some things ourselfs if needed, I don't like a dll file to be able to mess with scripts I don't want. For this reason I also would prefer a [Reordable] Attribute instead of a [NotReorderable]...

    Anyway, the idea is great and simple, the price and docs are good, drop the dll and I will rate it 5 stars...

    Cheers,
    Franco Palmieri - Fronne
     
  7. Fronne

    Fronne

    Joined:
    Sep 25, 2014
    Posts:
    112
    Unity 5.4.3p1 same problem in your own Demo Scene...
    Works once, After Play or Scene Changed a NullReferenceException shows up trying to reorder again:

    NullReferenceException: SerializedObject has been Disposed
    UnityEditorInternal.ReorderableList.DoDraggingAndSelection (Rect listRect) (at C:/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:698)
    UnityEditorInternal.ReorderableList.DoListElements (Rect listRect) (at C:/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:556)
    UnityEditorInternal.ReorderableList.DoLayoutList () (at C:/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:373)
    UnityEditor.ReorderableArrayEditor.DrawReorderableArray (UnityEditor.SerializedProperty property)
    UnityEditor.ReorderableArrayEditor.DrawProperty (UnityEditor.SerializedProperty property, Boolean drawReorderableArrays)
    UnityEditor.ReorderableArrayEditor.DrawDefaultInspector ()
    UnityEditor.ReorderableArrayEditor.OnInspectorGUI ()
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1235)
    UnityEditor.DockArea:OnGUI()

     
  8. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Hey Fronne, thank you for your report. I will look into that and report back!
     
    Fronne likes this.
  9. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    The bug has been fixed and a new version is in review.
     
    Fronne likes this.
  10. Fronne

    Fronne

    Joined:
    Sep 25, 2014
    Posts:
    112
    Works perfect now, Thnx!
     
  11. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Super, I'm glad I could help!
     
    Fronne likes this.
  12. beeboks

    beeboks

    Joined:
    Aug 11, 2013
    Posts:
    11
    Hi,
    I just purchased your plugin and it's not working for me in Unity 5.5.0f3. I loaded up the demo scene and am not seeing any way to reorder any of the lists in the ArrayTest GO. Pressed play and no errors or anything showed up.

     
  13. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Sorry for late reply, I was on vacation...

    Please test in a new project and have a look at the menu "Tools|Reorderable Arrays" to enable and disable.
     
  14. Tropobor

    Tropobor

    Joined:
    Mar 24, 2014
    Posts:
    73
    Same here as beeboks...? What does the demo is supposed to demo ??? Very intriguing...
     
  15. Diet-Chugg

    Diet-Chugg

    Joined:
    Jul 4, 2012
    Posts:
    51
    Does this support System.Collection.Generic.List or just arrays?
     
  16. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    It supports both.
     
    Diet-Chugg likes this.
  17. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    It shows the reorderable arrays in the inspector if you select the objects wich contain lists
     
  18. isasaurio

    isasaurio

    Joined:
    Nov 13, 2016
    Posts:
    18
    Hello
    How can I edit or access by code an array created with eeste assets?
    For example if I want to change by code the

    GameObject of the PLAYER 1 "Classic Player List"

    ???

    Regards!!
     
  19. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    Does this work with Unity 5.6? I had created my own similar reorderable lists, but it stopped working in 5.6. I don't feel like taking the time to try and fix it, so looking for an alternative.
     
  20. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Yes, it still works with 5.6 and with 2017
     
  21. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    I turned on nested arrays and got this:

    upload_2017-7-29_7-39-10.png
     
  22. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Please send me a code snipped of your structure, I would like to debug this. Do you have custom Inspector renderer?
     
  23. Harrison_Chen

    Harrison_Chen

    Joined:
    Apr 21, 2017
    Posts:
    3
    Hello,

    I got a problem when my array is growing large as 50 elements, the inspector is getting slow.

    then I try the demo file, and add element to 200, the Unity even crashed.

    My Unity version is 2017.1, does it have any solution?
     
  24. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Sorry, I don't think I can fix this, since the plugin uses Unity-Editor-Components which seem to be the cause for this. Perhaps this will be fixed/improved with a new Unity Version.
     
  25. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    Hello TheGering,

    I bought your tool and it looks nice, but unfortunately it doesn't seem to work inside custom Serializable classes. Which is where most of my long lists are.

    So this doesn't work:

    Code (csharp):
    1.  
    2.  
    3. [System.Serializable]
    4. public class SerializableTest {
    5.     public int[] intArrayTest;
    6. }
    7.  
    8. public class MyClass : MonoBehaviour {
    9.     public SerializableTest serializableTest;
    10. }
    11.  
    12.  
     
  26. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Hello TommiH,

    this should work, see the DemoMonoBehaviour.cs. It uses a custom class:

    Code (CSharp):
    1. [Serializable]
    2. public class Player {
    3.     public string name;
    4.     public GameObject obj;
    5.     public string[] items;
    6.     public int life;
    7.     public float damage;
    8.     public int level;
    9.     public MagicSpell[] spells;
    10.     public Vector3[] wayPoints;
    11.     public Quaternion[] orientations;
    12. }
    13.  
    Make sure, to enable the plugin via menu. And make sure there is not another CustomEditor. If this is the case, you have to extend from ReorderableArrayEditor.
     
  27. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    It seems to work with arrays of custom classes, but try adding a single reference to your Demo class instead:

    Code (csharp):
    1.  public Player singlePlayer;
    Look inside that one in the inspector, and the items, spells, and orientations don't become reorderable.
     
  28. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    164
    I also have an issue getting it to work with custom serializable classes, like this one:

    [System.Serializable]
    public struct ParticleEffect
    {
    public ParticleSystem[] m_particlesToPlay;
    }

    If I add a field of type ParticleEffect to my MonoBehaviour, then the particlesToPlay array is not reorderable. I have of course enabled the plugin in the editor (and it works for "normal" arrays), and I have enabled support for nested arrays. I do not have a custom editor for this struct.

    Any way to get this working?

    Thank you very much in advance.
     
  29. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    That should work with the next release of the tool. I am going to ship the source code (or parts of it), but I have to refactor first...
     
  30. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I have about 400 array item of prefabs, and it is way too slow to work with. Is there anything we can do about it?
     
  31. SeigneurNecron

    SeigneurNecron

    Joined:
    Sep 2, 2016
    Posts:
    10
    Hello, I'm using your asset on Unity 2017.1. It works great, except if I use a custom PropertyDrawer on a List field.

    Here is the code for my PropertyDrawer classes:
    Code (CSharp):
    1.     public abstract class HideIfPropertyDrawer<T> : PropertyDrawer where T : HideIfAttribute {
    2.  
    3.         // Fields :
    4.  
    5.         protected T hideIf;
    6.         protected SerializedProperty comparedProperty;
    7.  
    8.         private bool hidden = false;
    9.  
    10.         // Methods :
    11.  
    12.         public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
    13.             return this.hidden ? 0f : base.GetPropertyHeight(property, label);
    14.         }
    15.  
    16.         public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
    17.             this.hideIf = this.attribute as T;
    18.             this.comparedProperty = property.serializedObject.FindProperty(this.hideIf.ComparedProperty);
    19.             bool shouldHide = false;
    20.  
    21.             if(this.comparedProperty != null) {
    22.                 shouldHide = this.ShouldHide();
    23.             }
    24.             else {
    25.                 Debug.LogError("There is no property with name " + this.hideIf.ComparedProperty + "!");
    26.             }
    27.  
    28.             if(!shouldHide) {
    29.                 this.hidden = false;
    30.                 EditorGUI.PropertyField(position, property);
    31.             }
    32.             else if(this.hideIf.HideType == HideType.Disable) {
    33.                 this.hidden = false;
    34.                 GUI.enabled = false;
    35.                 EditorGUI.PropertyField(position, property);
    36.                 GUI.enabled = true;
    37.             }
    38.             else {
    39.                 this.hidden = true;
    40.             }
    41.         }
    42.  
    43.         protected abstract bool ShouldHide();
    44.  
    45.     }
    46.  
    47.     [CustomPropertyDrawer(typeof(HideIfBoolAttribute))]
    48.     public class HideIfBoolPropertyDrawer : HideIfPropertyDrawer<HideIfBoolAttribute> {
    49.  
    50.         // Methods :
    51.  
    52.         protected override bool ShouldHide() {
    53.             if(this.comparedProperty.propertyType == SerializedPropertyType.Boolean) {
    54.                 return this.comparedProperty.boolValue == this.hideIf.ComparedValue;
    55.             }
    56.             else {
    57.                 Debug.LogError("The property " + this.hideIf.ComparedProperty + " is not of type bool!");
    58.                 return false;
    59.             }
    60.  
    61.         }
    62.  
    63.     }
    I don't see a ReorderableArrayPropertyDrawer I could extend instead of PropertyDrawer (like I can extend ReorderableArrayEditor instead of Editor). What should I do?
     
  32. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
    I must already derive from GridBrushEditor (tho i not use any GUI) so i cannot derive from ReorderableArrayEditor!?
    Why does my CustomPropertyDrawer work in this situation but not Reorderable?
    Is there any way to make it work?
    Thanks.
     
    Last edited: May 28, 2018
  33. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Sorry, I do not have any solution yet.
     
  34. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Could you please contact me via mail (support at tiny-plugin.com) and send me a test project and the complete code of HideIfBoolPropertyDrawer?
     
  35. Nimdanet

    Nimdanet

    Joined:
    Jan 19, 2013
    Posts:
    38
    Is any possible to work as inverse? I use some tag [Reordable] to only make reordable the arrays that I want instead all arrays are reordable by default and I should use [NotReordable]? If it's something easy you can instruct me and I change on my project only.

    Thanks
     
  36. oliver_unity892

    oliver_unity892

    Joined:
    Oct 28, 2019
    Posts:
    91
    Hi
    Does this work with 2019.2 ?

    Olly
     
  37. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    stopped working on 2020.1.17f. Any updates on this?
     
  38. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    I am trying to use with Mirror Networking so need to use NetworkBehaviour instead of monobehaviour. Is this why it wont work?