1
2

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 3 years have passed since last update.

(Unity) インスペクタでpublicを使わずインスペクタで編集できるようにする方法

Last updated at Posted at 2017-08-01

SerializeFieldでそれが可能

SerializeFieldとは、"privateフィールドを強制的にシリアライズする"ものです。 要するに、インスペクタから変数の値を変更したかったらpublicをつければいいが、[SerializeField]をつければ、privateやprotectedな変数でもインスペクタから値を変更できるようになる。
I_am_hentai.cs
    [SerializeField]
    private Vector3 initializeAngle;

privateつけた変数だけど、、、

スクリーンショット 2017-08-01 13.07.38.png

private変数でもインスペクタから値を変更できるようになりました。
プレファブとかをドラッグ&ドロップするためになんでもpublicしなければいけないわけで
これは便利。これでpublicつけるデメリットが!!

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?