30. 不正スクリプト修正(一例)
30
❏ MonoBehaviour の new
Unity の作法としてそもそも is not allowed.
対応スクリプト: new キーワードに続くシンボル名で GetAssemblies して
IsSubclassOf(typeof(MonoBehaviour)) だったら検出
❏ NameToLayer をクラス変数に代入
少し気付き難いが実行時エラーとなる
AddComponent() 出来ない、のちに Null 参照などの原因となる
“NameToLayer is not allowed to be called from a MonoBehaviour constructor”
対応スクリプト: NameToLayer() の論理行頭に private などの修飾子があれば検出
初歩的ミス、仕様勘違いは
スクリプトでチェック