unity HideInInspector與SerializeField

來源:互聯網
上載者:User

標籤:os   sp   代碼   c   ef   r   程式   ui   return   

[HideInInspector]表示將原本顯示在面板上的序列化值隱藏起來。[SerializeField]表示將原本不會被序列化的私人變數和保護變數可以序列化,這麼他們在下次讀取時,就是你上次賦值的值。1如果a是公有的序列化變數。1.1如果你想要在面板中看到a,那麼用:public int a;1.2如果你不想在面板中看到a,那麼用:[HideInInspector]public int a;// 這樣a可以在程式中被代碼賦值,但不會在面板中看到並手動設定賦值。2 如果a是私人的序列化變數,你想在面板中讀取並儲存,那麼用:[SerializeField]private int a;3.如果a是私人的序列化變數,你想在面板中讀取,但是不儲存,那麼用:[HideInInspector][SerializedField]private int a;public int b{    get{return a;}}然後在Editor中顯示,EditorGUILayout.LabelField("value",game.B.ToString());4如果a是私人序列化變數,你不想在面板中做任何操作(不想看到,也不想寫),但是想要在程式中給它賦值,那麼用。[HideInInspector][SerializedField]private int a;public int b{    get{return a;}    set{a = value;}}

unity HideInInspector與SerializeField

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.