Unityシリアル化フィールド[SerializeField] [HideInInspector []



Unity Serialization Field



[HideInInspector]は、パネルに最初に表示されていたシリアル化された値を非表示にすることを意味します。
[SerializeField]は、他の方法ではシリアル化されないプライベート変数と保護変数をシリアル化できることを意味します。したがって、次に読み取る値は、最後に割り当てた値です。 。

注意:



  • aがパブリックシリアル化変数の場合。

    (1) If you want to see the variable a in the panel, then use: public int a (2) If you don't want to see the variable a in the panel, use: [HideInInspector] public int a This way a can be assigned by the code in the program, but it will not be seen in the panel, nor can it be set manually.
  • aがパネルで読み取り、割り当てるプライベートシリアル化変数である場合は、次を使用します。



    [SerializeField] private int a
  • aがパネルで読み取りたいが値が割り当てられていないプライベートシリアル化変数である場合は、次を使用します。

    [HideInInspector][SerializedField] private int a public int b { get{return a} } Then displayed in the Editor, EditorGUILayout.LabelField('value', game.b.ToString())
  • aがプライベートシリアル化変数である場合、(表示したくない、変更したくないが、プログラムで値を割り当ててから使用したい)。

    [HideInInspector][SerializedField] private int a