Skip to content
プロジェクト

概要

Unityゲームエンジンのコンポーネント向けに、並べ替え可能なリストを自動生成します。

ゲーム・エミュレーター

この数値の測り方

計測したスター増加

24時間
0
7日間
0
15日間
0
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

Reorderable Inspector

Automatically turn arrays/lists into ReorderableLists in Unity inspectors. Inspired by Alejandro Santiago's implementation.

Sortable Array

This is an editor enhancement that gives you nicer inspector features without having to write additional code. Easily rearrange arrays, add buttons for utility functions, and and edit linked ScriptableObjects right in your GameObject's inspector.

Installation

Download the UnityPackage from the latest releases and import it into Unity. The directory can be moved after being imported.

Usage

To draw an array as a ReorderableList, mark the property with the Reorderable attribute.

// Add this `using` statement to the top of your file
using SubjectNerd.Utilities;

public class ListReorderTest : MonoBehaviour
{  
	[Reorderable]
	public string[] stringArray; // This will be drawn with a ReorderableList

	public List<string> stringList; // This will be drawn as a default array
}

If you want to apply the reorderable list to all arrays, edit ReorderableArrayInspector.cs and uncomment the defines at the top of the file

Additional Features

ContextMenu buttons.

Quickly add buttons for utility functions to the inspector by using Unity's ContextMenu attribute

public class ContextMenuTest : MonoBehaviour
{
	public bool isTestEnabled;

	[ContextMenu("Test Function")]
	private void MyTestFunction()
	{
		Debug.Log("Test function fired");
	}

	[ContextMenu("Test Function", isValidateFunction:true)]
	private bool TestFunctionValidate()
	{
		return isTestEnabled;
	}

	[ContextMenu("Other Test")]
	private void NonValidatedTest()
	{
		Debug.Log("Non validated test fired");
	}
}

Context Menu

Inline ScriptableObject editing

Edit settings stored in a ScriptableObject in the inspector with the EditScriptable attribute. A feature inspired by Tom Kail's ExtendedScriptableObjectDrawer

public class SkinData : ScriptableObject
{
	public string id;
	public Sprite sprite;
}

public class TestEntity : MonoBehaviour
{
	public string entityName;
	
	// Add the `EditScriptable` attribute to edit the `ScriptableObject` in the GameObject inspector
	[EditScriptable]
	public SkinData skin;
}

Limitations

  • Only supports Unity 5 and above
  • ReorderableLists of class instances may be a little rough, especially below Unity version 5.3
  • Custom inspectors will not automatically gain the ability to turn arrays into reorderable lists. See next section.

Custom inspectors

Custom inspectors will not automatically draw arrays as ReorderableLists unless they inherit from ReorderableArrayInspector.

This class contains helper functions that can handle default property drawing. Below is a template for a custom inspector.

Additional custom inspector functionality is discussed in the wiki.

Inspector Template

[CustomEditor(typeof(YourCustomClass))]
public class CustomSortableInspector : ReorderableArrayInspector
{
	// Called by OnEnable
	protected override void InitInspector()
	{
		base.InitInspector();
		
		// Always call DrawInspector function
		alwaysDrawInspector = true;
		
		// Do other initializations here
	}
	
	// Override this function to draw
	protected override void DrawInspector()
	{
		// Call the relevant default drawer functions here
		// The following functions will automatically draw properties
		// with ReorderableList when applicable
		/*
		// Draw all properties
		DrawPropertiesAll();

		// Like DrawPropertiesExcluding
		DrawPropertiesExcept("sprites");

		// Draw all properties, starting from specified property
		DrawPropertiesFrom("propertyName");

		// Draw all properties until before the specified property
		DrawPropertiesUpTo("endPropertyName");

		// Draw properties starting from startProperty, ends before endProperty
		DrawPropertiesFromUpTo("startProperty", "endProperty");
		*/
		
		// Write your custom inspector functions here
		EditorGUILayout.HelpBox("This is a custom inspector", MessageType.Info);
	}
}

Buy me a coffee!

If this Unity enhancement is useful to you, it would be great if you could buy me a coffee!

関連プロジェクトを探す

読み込み中…