3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Tips エディタ 配列フィールドの超簡単なソート

Posted at

Unityの配列フィールドに複数のオブジェクトをぶち込むと、全然ソートされずによくわからん順番になるのですが。
OnValidateメソッドで、ソートしてあげれば簡単!ということに気づきました。

SampleUnityPropertySort.cs

using UnityEngine;
using System.Collections;
using System.Linq;

public class SampleUnityPropertySort : MonoBehaviour {
	
	public Sprite[] sprites;
	
	void OnValidate() {
		sprites = sprites.OrderBy(sprite => sprite.name).ToArray();
	}
}

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?