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

InspectorでスクリプトのOn/Offを行うチェックボックスの出現条件

Last updated at Posted at 2015-10-27
InspectorでScript名の左側にあるチェックボックス
  • Scriptのenable/disableをあらかじめ設定できるものですが、表示されないScriptもあります。

  • チェックボックス出ている例

  • スクリーンショット 2015-10-27 17.40.13.png

  • チェックボックス出ていない例

  • スクリーンショット 2015-10-27 17.47.21.png


出たり出なかったりする原因は?
  • Update系メソッドをクラス内で宣言している場合のみ、チェックボックスが出るみたい。
サンプル
GameController.cs
public class GameController : MonoBehaviour 
{
	// 宣言するとチェックボックスが表示されるメソッド例
	void Update(){}
	void FixedUpdate(){}
	void LateUpdate(){}
	void OnEnable(){} 

	// チェックボックスが表示されないメソッド例
	void Awake(){}
	void Start(){}
	void OnValidate(){}
}

  • 実行中に更新されることがないクラスについてはチェックボックスを出す必要が無いだろう・・・ということのようです。

  • 条件となるメソッドは他にもある模様ですが、全部は調べてません。Startとかも含んでほしかったかも…


まとめ
  • InspectorからScriptのEnable/Disableをあらかじめ設定したい場合は、Update系メソッドを宣言しておく必要がある。
2
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
2
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?