subclass default values in list

Any idea why the test variable default value isn’t -1 in the inspector? It’s always 0 no matter what I define in the script.

	[Serializable]
	public class BaseClass {
        public int test = -1;
	}
	
	[Serializable]
    public class ListClass {
		public string foo;
						
		[Serializable]
		public class SubClass : BaseClass {
			public string bar;
		}

		public SubClass subClass = new SubClass();
    }
	
	public List<ListClass> listClass = new List<ListClass> ();

alt text

The inspector overwrites values of serialized items after construction. For the behavior the you want, you can set values on the constructed Data instances in Start or OnAfterDeserialize.

Take a look here:

Anyone still looking might wanna take a look at this answer
link to answer