unity serializefield vs public code example

Example 1: unity serializefield

//Shows the private variable in the Unity Inspector
[SerializeField]
private string name;

Example 2: difference between public and serializefield unity

•Serialisable fields show up in the inspector. 

Here are the four different possible combinations:

public 				//Show up in inspector and accessible by other scripts
[SerialiseField] 	//Show up in inspector, not accessible by other scripts
[HideInInspector]	//Doesn't show in inspector, accessible by other scripts
private  			//Doesn't show in inspector, not accessible by other scripts