コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】Inspector における Transform の表示を拡張したり使える Attribute が増えたりする「Inspector Gadgets」紹介($5.40、無料版あり)

f:id:baba_s:20171121193033p:plain

概要

2017/3/9 に「Inspector Gadgets」がリリースされました

「Inspector Gadgets」を導入すると、
Inspector における Transform の表示を拡張したり
使える Attribute が増えたりします

検証環境

  • Unity 2017.1.1f1
  • Inspector Gadgets 4.2

Transform の表示

f:id:baba_s:20171121193323p:plain

「Inspector Gadgets」を導入すると
Inspector における Transform の表示が拡張されます

項目 内容
L 座標系を変更(L:ローカル、W:ワールド)
F 子オブジェクトを固定するかどうか
G 選択中のすべてのオブジェクトのギズモを表示
= スケールを均一にするかどうか
C 値をコピー
P 値を貼り付け
S 値をスナップ
マウスホイールをクリック 値をリセット

スクリプトの表示

f:id:baba_s:20171121194105p:plain

スクリプトのファイル名の表示欄が非表示になります
(マウスホイールをクリックするとスクリプトをエディタで開きます)

コンテキストメニュー

「Inspector Gadgets」を導入すると
コンテキストメニューに項目が追加されます

独自コンポーネント

f:id:baba_s:20171121195338p:plain

項目 内容
Create Editor Script エディタ拡張用のスクリプト作成
Ping Script Asset Project ビューのスクリプトファイルをハイライト

コンポーネントの変数

f:id:baba_s:20171121195541p:plain

コンポーネントの変数を右クリックすると
FindObjectOfType や GetComponent が実行できます

Attribute

「Inspector Gadgets」を導入すると
使用できる Attribute が追加されます

Toolbar

列挙型の変数の値を変更しやすくします

[Toolbar]
public TextAlignment textAlignment;

f:id:baba_s:20171121194451p:plain

Color

GUI の色を変更します

[Color(1, 0.5f, 0.5f)]
public string coloredField = "I'm Red";

f:id:baba_s:20171121194531p:plain

Euler

クォータニオンをオイラー角で設定できます

[Euler]
public Quaternion quaternionField;

f:id:baba_s:20171121194625p:plain

Labelled Collection

配列の要素に名前を付けます

[LabelledCollection( "Up", "Down", "Left", "Right" )]
public Vector3[] directions;

f:id:baba_s:20171121194732p:plain

Readonly

変数を読み取り専用にします

[Readonly]
public string readonlyField = "Can't touch this";

f:id:baba_s:20171121194810p:plain

Label

プロパティの値を表示します

[Label]
string PropertyLabel { get; set; }

f:id:baba_s:20171121194917p:plain

Button

関数を実行できるボタンを表示します

[Button]
void InspectorButton() {}

f:id:baba_s:20171121195000p:plain

設定

f:id:baba_s:20171121195951p:plain

Unity メニューの「Edit>Preferences...」を選択して、
「Inspector Gadgets」を選ぶと設定を変更できます

無料版

「Inspector Gadgets」にはいくつかの機能が制限された無料版が存在します