cfoulston / unity-reorderable-list Goto Github PK
View Code? Open in Web Editor NEWExtended version of the Reorderable List in Unity
Home Page: https://forum.unity3d.com/threads/reorderable-list-v2.339717/
License: MIT License
Extended version of the Reorderable List in Unity
Home Page: https://forum.unity3d.com/threads/reorderable-list-v2.339717/
License: MIT License
Unity Version: 2018.3.0b10
Unable to load the icon: 'MiniPopupNoBg'.
Note that either full project path should be used (with extension) or just the icon name if the icon is located in the following location: 'Assets/Editor Default Resources/Icons/' (without extension, since png is assumed)
UnityEditor.ReorderableList:DoLayoutList()
PatternInspector:OnInspectorGUI() (at Assets/Editor/Patterns/PatternInspector.cs:44)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Is there an easy way to add attributes to the inner array
field in ReorderableArray
?
So far the options I've come up with are:
List<>
with my own attributes applied and create a custom editor that uses a ReorderableList
.ReorderableArray
class with my own attributes applied.ReorderableArray
so that it is extensible i.e. make array
an abstract property and child classes can apply their own attributes as needed.I'm curious if you've come across this problem and know of an alternate solution or if one of the above is the best way to go.
Hey there, I can't edit certain types by clicking on them. Unity simply doesn't highlight/activate the field that was clicked on. In this case I am serializing a ReorderableArray<Vector3>
. I've only been able to replicate the issue with Vector2s and Vector3s - Vector4s work fine, as do single field types such as strings or floats. Maybe this is because Vector4 elements expand? It could have something to do with the fact that the fields for the Vector3 x y z values are on the same area that can be dragged to move the element. I can tab to those fields to highlight and edit them, but that's rather cumbersome. I'm using Unity 5.5.0f3
Thanks for building this! It's speeding up my workflow quite a bit
Order is not preserved during dragging at high speed.
Also, potentially look at removing DragElement class, shouldn't be necessary if modifying the Serialized list directly
In my case, when objects are drag-n'-dropped over a rect, any components matching the list type are added. As you can see in the video, an error is only thrown if multiple objects are being inspected.
Video: https://streamable.com/83h5k
Error: InvalidOperationException: The operation is not possible when moved past all properties (Next returned false)
Full Error: https://pastebin.com/gC3yteZb
The error points to line 556 in ReorderableList.cs
private float GetElementHeight(SerializedProperty element) {
if (getElementHeightCallback != null) {
return getElementHeightCallback(element) + ELEMENT_HEIGHT_OFFSET;
}
else {
// error points to the line below
return EditorGUI.GetPropertyHeight(element, GetElementLabel(element, elementLabels), IsElementExpandable(element)) + ELEMENT_HEIGHT_OFFSET;
}
}
When creating a new object with the + button all the fields in the new object are set to the c# default for that type instead of their default values from the class constructor (ints + floats = 0, string = empty, bool = false).
I've tested by adding a field next to the list that is a singular object. This object is initialised correctly, but the objects in the list are not. How can I get this working correctly?
The current number of pages can only be counted,Can you make pages by some tag(SerializedProperty.id name tag... or Fuc<SerializedProperty,sting>callback )
Hi, Is it possible to modify lists of different scriptable objects selected at the same time?
C# uses whatever public GetEnumerator() is available in foreach. That's why List and Array have versions which returns a struct instead of IEnumerator.
Only having IEnumerator GetEnumerator() causes vcalls and boxing, or worst case allocation if you have a class that implements the interface. Easiest and most performant solution would be to just implement the existing one explicitly and expose the List.Enumerator in the public. Another solution would be to write your own but then that would need to wrap the list enumerator causing unnecessary copying or use the indexing operator of the internal list and that is not desirable.
I'm using a nested reorderable list within a reorderable list for my AI editor, something like this:
public ActionTrigger[] actions;
[Serializable]
public class ActionTrigger {
[Reorderable(paginate = true, pageSize = 1)] public ActionSetList actionSetList;
}
[Serializable]
public class ActionSet {
}
When there are 4+ elements within the nested list, it starts to lag unity significantly. I've tried to tackle this somewhat by enabling paging, but it's still noticeable.
Is there a way to address this?
Hey man,
great work you're doing!
But I got a little problem with your ReorderableList and Unity's "Select Object" Popup.
If I take your GameObjectExample script as an example, everything works well with drag and drop, but if I want to select the GameObject via the list window, it does not work. Here a little example screenshot:
When I click on the small circle, a new window pops up. Normally I could just select the GameObject, but from your List it doesn't work. As you can see in the screenshot, I actually already selected another GameObject, but the List content doesn't change.
Any idea on how this could be fixed?
(I use Unity 2019.4.13f1)
How can we make an Reorderable-List for things like gameobject??
(which can't be inherited from the required class)
Since this is a plugin and not a project, it would be beneficial to not include the entire unity project folder in the repo. It would be simpler to navigate, and would allow users to add your plugin as a git submodule directly in their projects.
The repo root should then contain the following files/folders:
I'm not the only one who thinks this is a better approach, here's a fork (not mine) that has done about the same thing.
https://github.com/Cippman/Unity-Reorderable-List
I can send a pull request if you agree with these changes
Hi @cfoulston,
Thanks for making this awesome UPM package. I'm the creator of the OpenUPM platform, an open-source UPM registry, and continuous build service based on Git tags. It's hosting more than 200+ open-source UPM packages at the time of writing.
To make it happen, I would suggest you make GitHub releases (which create Git tags) for version control. It can be achieved either manually or using an automatic approach.
After your GitHub release, our build pipelines will detect the changes and build UPM packages in 5-10 minutes. Then you can visit your package at https://openupm.com/packages/com.malee.reorderablelist/.
Hopeful this makes sense for you.
I noticed that ever since I included this package I can't seem to be able to initialize a generic list using anything but the default constructor even when I'm not referencing the namespace.
For now I'm working around it by adding using Generics = System.Collections.Generic;
and then using new Generics.List<T>(int)
in my code, but it would be awesome if this package would either not mess with the linking of Generics or provide those constructor overloads.
It seems like I should be able to do a simple .Add() to add a new item to a reorder able array to add an item at run time. I am getting errors however, but I'm also not yet sure if it is my fault or not. Any suggestions?
Hey there,
Is it possible to use this in an editor window? I was hoping to use it in a current small project that is using 2017.1.5, but I can't seem to get it. I looked around a bunch and saw that for this type of thing you typically have to use something similar to this:
list = serializedObject.FindProperty("list2");
EditorGUILayout.PropertyField(list, new GUIContent("My List Test"), true);
Unfortunately, though, I have been unable to get it working successfully, so I just wanted to see if it was even possible?
Thanks,
-MH
Hi,
I'm using DrawElementCallback to display my custom fields.
But I can't make them appear right when they folded.
Elements unfolded
Elements folded
private void ElementDraw(Rect position, SerializedProperty property, GUIContent label, bool selected, bool focused)
{
position.width = 200; position.height = 20;
EditorGUI.BeginProperty(position, label, property);
targetType = property.FindPropertyRelative("type");
int newselectedTarget = EditorGUI.Popup(position, targetType.intValue, levelData?.GetTargetsNames());
targetType.intValue = newselectedTarget;
position.y += 20;
EditorGUI.PropertyField(position, property.FindPropertyRelative("count"), GUIContent.none);
EditorGUI.EndProperty();
}
https://github.com/cfoulston/Unity-Reorderable-List.git
Console shows an error:
Error adding package: .
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
Not sure if this is a problem with this project or with Unity...
Have I written this title correctly?
Suppose I have a class Prize
, and I want to make a Reorderable List for it.
Now I have different types of Prizes that each has its own class that inherits from Prize
, for example CoinPrize
, that besides having the original attributes, also have a amount
attribute, that I want to also modify in the inspector.
Since obviously you can't add items to the list and expect the class to magically know what type of item you want, I have create separated buttons, each that adds a specific class child for the list
But in the inspector, even if adding the element via the correct button, the child class attributes doesn't show up:
Is there any way I can make this work?
Not sure if this is a bug in Unity but this only seems to happen with ReorderableArrays where the first time the inspector is rendered it uses the wrong height and the second render corrects it.
I've printed out the height returned by ReorderableDrawer which is always correct so I'm wondering if this is just an issue in Unity 2019.3 or if there is some way to fix this?
Thx to the change for #4, I am able to modify the array at runtime.
But since we often just copy a standard List onto ReorderableArray (which is now also a IList), I would suggest adding a simple CopyFrom
API that takes a IList<T>
, and one might do:
public IList<SomeObject> CustomArray
{
get { return _customArray; }
set { _customArray.CopyFrom(value); }
}
This is completely do-able in userland, so just a suggestion for enhancement.
Same idea is also present at https://github.com/azixMcAze/Unity-SerializableDictionary
(by the way, my use case is actually exposing this property to editor script, which allows me to migrate values from a List field to ReorderableArray field, as I couldn't find a way to use FormerlySerializedAsAttribute to automate this process.)
Is it possible to use the ReordableList inside a PropertyDrawer? I am not using Attributes.
What I'm doing in OnGUI is initializing the ReorderableList with the property and then 'DoList'. However it looks like when I change one item of the list it does the same for all of them.
I somehow missed the custom names in the example script :p
It would be useful to have the option to paginate the in-editor view of a reorderable list.
For example (and this could be hardcoded), only 100 entries are shown, and if there are more a small page UI is visible next to the +/- at the bottom, which shows "page X / Y" where X is editable by the user.
With 315 entries you would by default see "Page 1 of 4" with the first 3 pages having 100 elements visible and page 4 only 15 entries.
Optionally there could also be an input field for 'elements per page' or 'page size'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.