LoginSignup
0
0

More than 3 years have passed since last update.

【UniRx】ReactiveProperty<> をインスペクタに表示させる

Last updated at Posted at 2021-04-08

備忘録です
通常ReactivePropertyはインスペクタ表示できないけど、ちょちょいといじれば表示させられるっぽい

やることは2つ

①自前でReactivePropertyを継承したクラスを作って、そいつに[System.Serializable]をつける
②InspectorDisplayDrawerを継承したクラスを作って、①で作ったクラスを指定する

実装

①の実装

①自前のReactivePropertyの作成.
/// <summary>
/// インスペクタに表示できるReactiveProperty<int>
/// </summary>
[System.Serializable]
public class IntReactiveProperty : ReactiveProperty<int>
{
    public IntReactiveProperty()
    {
    }
}

①だけでもとりあえず表示は可能。ただ以下のようにインスペクタにはこんな感じでが出てくる.
スクリーンショット 2021-04-08 17.27.21.png

いちいちToggle開くのはめんどいので、②を実装する

②の実装

②InspectorDisplayDrawerの指定.
/// <summary>
/// IntReactivePropertyを直接インスペクタからいじれるようにする(Toggleなしにできる)
/// </summary>
[CustomPropertyDrawer(typeof(IntReactiveProperty))]
public class AddInspectorDisplayDrawer : InspectorDisplayDrawer
{ }

するとこうなる

スクリーンショット 2021-04-08 17.28.42.png

直接いじれて素敵〜〜〜!

参考リンク

0
0
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
0
0