Unity3d Serialization Serializefield

Source: Internet
Author: User

First, Unity automatically serializes the public variable, which means that the serialized variable is valued when it reads unity again, and does not require you to assign a value again because it has been saved. Then, what value will be displayed on the panel? The value that has been serialized, but not marked with Hideininspector. [Hideininspector] means that the serialized values that were originally displayed on the panel are hidden. [Serializefield] means that private variables and protection variables that would not otherwise be serialized can be serialized, so that they will be the value of your last assignment at the next read. 1 If A is a public serialization variable. 1.1 If you want to see a in the panel, then use: public int a;1.2 If you don't want to see a in the panel, then use: [Hideininspector]public int a;//so that a can be assigned to code in the program, However, you will not see it in the panel and set the assignment manually. 2 If A is a private serialization variable that you want to read and save in the panel, then use: [Serializefield]private int a;3. If a is a private serialization variable, you want to read it in the panel, but not save it, then use: [hideininspector][ serializedfield]private int A;public int b{get{return A;} Then display in editor, Editorguilayout.labelfield ("value", game. B.tostring ()); 4 If A is a private serialization variable, you do not want to do anything in the panel (you do not want to see it, you do not want to write it), but you want to assign a value to it in the program. [Hideininspector]    [serializedfield]private int a;public int b{get{return A;} Set{a = value;}}

Unity3d Serialization Serializefield

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.