けいごのなんとか

Unityユーザーとしてのブログ。ギリギリ路線走ってます。

コンポーネントの順番を変更する「Component Move Up」「Component Move Down」をコードで管理する

何度も「Move Up」とか押しまくるの疲れたので作ってみた

Github - https://github.com/anchan828/ComponentOrderAttribute

コンポーネントの「Move Up」「Move Down」をコードで自動管理

ComponentOrderAttribute

ComponentOrderAttribute(uint order)

指定した順番通りに並び替える。

ただしTransformは必ず一番上でなければいけない。

using UnityEngine;
using System.Collections;

[ComponentOrder(1)]
public class Order1 : MonoBehaviour
{
}

ComponentOrderAttribute(Type type)

指定したTypeの直下に移動する

using UnityEngine;
using System.Collections;

[ComponentOrder(typeof(Rigidbody))]
public class OrderRigidbody : MonoBehaviour
{
}