unity show private variable in inspector code example
Example 1: show private fields in inspecotr unity
// You Can as well do this with "ScrpitableObject"s
public class MyClass : MonoBehaviour {
// Make sure that your field type is actually displayable on the inspector
[SerializeField] var myPrivateField
{
Example 2: unity how to show a private variable in inspector
//Will Show class in the inspector
[System.Serializable]
public class MyClass{
}
public class otherClass{
}
public MyClass thatClass; //will show
public otherClass thatotherClass; //will NOT show
public int public_int; // will show beacuse it's an public variable
private int private_int; // will NOT show beacuse it's an private variable
[SerializeField]
private private_int2; // will show beacuse it has an Serialize Field
protected int protValue; // will not show.