Skip to main content
Commonmark migration
Source Link

You're looking for the SerializeField Attribute

From the docs:

Force Unity to serialize a private field.

 

You will almost never need this. When Unity serializes your scripts, it will only serialize public fields. If in addition to that you also want Unity to serialize one of your private fields you can add the SerializeField attribute to the field.

Your code would then look like this:

public class SomeScript : MonoBehaviour{
    [SerializeField]
    private Button button;
}

You're looking for the SerializeField Attribute

From the docs:

Force Unity to serialize a private field.

 

You will almost never need this. When Unity serializes your scripts, it will only serialize public fields. If in addition to that you also want Unity to serialize one of your private fields you can add the SerializeField attribute to the field.

Your code would then look like this:

public class SomeScript : MonoBehaviour{
    [SerializeField]
    private Button button;
}

You're looking for the SerializeField Attribute

From the docs:

Force Unity to serialize a private field.

You will almost never need this. When Unity serializes your scripts, it will only serialize public fields. If in addition to that you also want Unity to serialize one of your private fields you can add the SerializeField attribute to the field.

Your code would then look like this:

public class SomeScript : MonoBehaviour{
    [SerializeField]
    private Button button;
}
Source Link

You're looking for the SerializeField Attribute

From the docs:

Force Unity to serialize a private field.

You will almost never need this. When Unity serializes your scripts, it will only serialize public fields. If in addition to that you also want Unity to serialize one of your private fields you can add the SerializeField attribute to the field.

Your code would then look like this:

public class SomeScript : MonoBehaviour{
    [SerializeField]
    private Button button;
}