C# class hidden in inspector

Hey, I’m trying to make a class within my main class in c#, but I can’t figure out why the class TestClass and its variables are not being shown in the inspector?

[System.Serializable]
public class TestClass {
	public int y;	
}

public class MainClass : MonoBehaviour {
	public int x;
}

There are not being shown because you don’t use them!

Try this:

[System.Serializable]
public class TestClass {
    public int y;  
}

public class MainClass : MonoBehaviour {
    public TestClass test;
}

Depending on your code, you might want to put it as

[System.Serializable]
public class MainClass : MonoBehaviour {
	public class TestClass {
		public int y;  
	}
	
    public TestClass test;
}

since it’s a more object-oriented approach.