Code Monkey home page Code Monkey logo

unity-reorderable-list's People

Contributors

cfoulston avatar leloctai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-reorderable-list's Issues

Unable to load the icon: 'MiniPopupNoBg'.

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)

Reorderable item force jump to the top

I create simple one dimension reorder-list based-on package Example, and Child object with one field
public Color[] color;
It's happens when I edit colors for any Item in a bottom.

image

Inner Array Attributes

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:

  1. Use a List<> with my own attributes applied and create a custom editor that uses a ReorderableList.
  2. Create a copy of the ReorderableArray class with my own attributes applied.
  3. Refactor 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.

Selection of elements of certain types is broken (Vector2, Vector3)

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

Fix Dragging at High Speed

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

Adding element to list via code throws error when multiple objects with reorderable list are selected

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

New elements added without correct default values.

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?

image

Expose the List<T>.Enumerator struct or similar

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.

Nested list unity lag

I'm using a nested reorderable list within a reorderable list for my AI editor, something like this:

image

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?

Select Object Popup not working

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:
image
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)

GameObject Reference

How can we make an Reorderable-List for things like gameobject??
(which can't be inherited from the required class)

Suggestion: Remove project files from repo

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.

  1. Move Assets/ReorderableList contents to root, and delete the remaining Assets folder
  2. Create an issue "screenshots" and post your screenshots there, then remove them from the repo
  3. Delete UnityPackageManager/. It seems to not be doing anything anyway

The repo root should then contain the following files/folders:

  • Example/
  • List/
  • Example.meta
  • List.meta
  • .gitignore
  • LICENSE.md
  • README.md

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

Version control

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.

asmdef conflicts with System.Collections.Generic

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.

Possible to use in an editor window?

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

DrawElementCallback foldout issue

Hi,
I'm using DrawElementCallback to display my custom fields.
But I can't make them appear right when they folded.
Elements unfolded
image
Elements folded
image

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

Package fails to add on Unity 2019.3

  • Open a project in 2019.3.
  • Go to the package manager.
  • Add from Git url: 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...

Recursion

When used in recursion, after 3 layers, I get a label field that says 'Array must extend from Reorderable Array'. Luckily, the game I'm working on only requires 3 layers, so I can still use it. Would be interesting to look into, though.

reorderable array recursion code
reorderable array recursion

List of base class does not draw the inheritance attributes

Have I written this title correctly?

Suppose I have a class Prize, and I want to make a Reorderable List for it.
image
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
image

But in the inspector, even if adding the element via the correct button, the child class attributes doesn't show up:

image

Is there any way I can make this work?

Strange Property Size on First Layout

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?

Screen Shot 2020-04-02 at 3 22 27 PM

Screen Shot 2020-04-02 at 3 22 31 PM

Would be great to have a CopyFrom method on ReorderableArray

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

Using the list in a PropertyDrawer?

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.

Pagination

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'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.