• Stars
    star
    170
  • Rank 222,351 (Top 5 %)
  • Language
    C#
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

List control for Unity allowing editor developers to add reorderable list controls to their GUIs.

unity3d-reorderable-list

List control for Unity allowing editor developers to add reorderable list controls to their GUIs. Supports generic lists and serialized property arrays, though additional collection types can be supported by implementing Rotorz.Games.Collections.IReorderableListAdaptor.

$ yarn add rotorz/unity3d-reorderable-list

This package is compatible with the unity3d-package-syncer tool. Refer to the tools' README for information on syncing packages into a Unity project.

screenshot

Features

  • Drag and drop reordering!
  • Automatically scrolls if inside a scroll view whilst reordering.
  • Easily customized using flags.
  • Adaptors for IList<T> and SerializedProperty.
  • Subscribe to add/remove item events.
  • Supports mixed item heights.
  • Disable drag and/or removal on per-item basis.
  • Drop insertion (for use with UnityEditor.DragAndDrop).
  • Styles can be overridden on per-list basis if desired.
  • Subclass list control to override context menu.
  • Add drop-down to add menu (or instead of add menu).
  • Helper functionality to build element adder menus.

Preview (showing drop insertion feature)

preview

Installation

The unity3d-reorderable-list library is designed to be installed into Unity projects using the npm package manager and then synchronized into the "Assets" directory using the unity3d-package-syncer utility. For more information regarding this workflow refer to the unity3d-package-syncer repository.

Alternatively you can download the contents of this repository and add directly into your project, but you would also need to download the sources of other packages that this package is dependant upon. Refer to the packages.json file to see these.

A couple of examples!

Serialized array of strings

private SerializedProperty wishlistProperty;
private SerializedProperty pointsProperty;

private void OnEnable()
{
    this.wishlistProperty = this.serializedObject.FindProperty("wishlist");
    this.pointsProperty = this.serializedObject.FindProperty("points");
}

public override void OnInspectorGUI()
{
    this.serializedObject.Update();

    ReorderableListGUI.Title("Wishlist");
    ReorderableListGUI.ListField(this.wishlistProperty);

    ReorderableListGUI.Title("Points");
    ReorderableListGUI.ListField(this.pointsProperty, ReorderableListFlags.ShowIndices);

    this.serializedObject.ApplyModifiedProperties();
}

List of strings

private List<string> yourList = new List<string>();

private void OnGUI()
{
    ReorderableListGUI.ListField(this.yourList, this.CustomListItem, this.DrawEmpty);
}

private string CustomListItem(Rect position, string itemValue)
{
    // Text fields do not like null values!
    if (itemValue == null) {
        itemValue = "";
    }
    return EditorGUI.TextField(position, itemValue);
}

private void DrawEmpty()
{
    GUILayout.Label("No items in list.", EditorStyles.miniLabel);
}

More examples

Refer to the docs/examples directory of this repository for further examples!

Contribution Agreement

This project is licensed under the MIT license (see LICENSE). To be in the best position to enforce these licenses the copyright status of this project needs to be as simple as possible. To achieve this the following terms and conditions must be met:

  • All contributed content (including but not limited to source code, text, image, videos, bug reports, suggestions, ideas, etc.) must be the contributors own work.

  • The contributor disclaims all copyright and accepts that their contributed content will be released to the public domain.

  • The act of submitting a contribution indicates that the contributor agrees with this agreement. This includes (but is not limited to) pull requests, issues, tickets, e-mails, newsgroups, blogs, forums, etc.

More Repositories

1

unity3d-tile-system

A tile system extension for the Unity game engine supporting 2D and 3D tiles.
C#
53
star
2

unity3d-package-syncer

A command line utility that synchronizes asset files from npm packages into an appropriate directory of a game project that is made using the Unity game engine. Please read through the readme before using.
JavaScript
41
star
3

unity3d-ordered-dictionary

Library for adding ordered dictionaries to custom `ScriptableObject` and `MonoBehaviour` classes in a way that can be serialized by Unity provided that the key and value types are serializable.
C#
34
star
4

unity3d-class-type-reference

An example npm package that contains some example assets to demonstrate how to create a package for use in games made using the Unity game engine.
C#
21
star
5

markdown-it-external-links

Plugin for markdown-it that adds CSS classes to links that fall outside of the specified internal domain(s).
JavaScript
13
star
6

unity3d-utils

Common utility functionality for Unity game projects.
C#
11
star
7

unity3d-editor-menu

Fluent style API for constructing custom editor menus presented using `GenericMenu` by default although alternative presentation can be configured for project.
C#
10
star
8

markdown-it-block-image

Plugin for markdown-it that detects and outputs block level images.
JavaScript
8
star
9

unity3d-localized-strings

A lightweight localization framework for Unity editor scripts.
C#
6
star
10

unity3d-custom-popup

Custom popup control for Unity editor interfaces that defers popup menu construction until shown. This is good for situations where the popup is relatively expensive to construct.
C#
4
star
11

unity3d-package-utils

Utility functionality for unity3d-package's to ease access to package assets and generated data assets.
C#
2
star
12

unity3d-zenject-services

Service and configuration management for Zenject in Unity games.
C#
1
star
13

unity3d-package-example

An example npm package that contains some example assets to demonstrate how to create a package for use in games made using the Unity game engine.
JavaScript
1
star