[C#] Making Custom Classes Editable in the Inspector without System.Serializable

SOLUTION:

As it turns out, I didn’t realize that C# did not default to copying values when they do assignment. I had a List currentSpawn in another class, and was calling loadPattern like this:

currentSpawn = spawner.loadPattern

This was then setting currentSpawn equal to the same thing as the List loadPattern returned. The fix was to implicitly tell it to copy:

currentSpawn = new List(spawner.loadPattern)

I think I’m either misunderstanding how System.Serializable works, or that I am simply doing this in wrong way, however, I have the following class Declaration:

using UnityEngine;
using System.Collections.Generic;

/// <summary>
/// Holds the data for an enemy spawn pattern
/// </summary>
public class SpawnPattern : MonoBehaviour {


	[System.Serializable]
	///<summary>
	///Spawn Data for one Enemy
	///</summary>
	public class spawnData{

		/// <summary>
		/// Enumerated enemy Data Type, can be PINWHEEL, KAMIKAZE, or MINIBOSS
		/// </summary>
		public EnemyType enemy;

		/// <summary>
		/// ID for the spawner
		/// </summary>
		public int spawnID;

		/// <summary>
		/// The time at which the enemy spawns
		/// </summary>
		public float spawnTime = 0;
	}

	/// <summary>
	/// List of all spawnable enemies during the level
	/// </summary>
	public List<spawnData> spawnPattern = new List<spawnData>();

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

	
	}

	/// <summary>
	/// Returns the pattern to be used by the Spawn Controller
	/// </summary>
	public List<spawnData> loadPattern
	{
		get
		{
			return spawnPattern;
		}
	}
}

Basically, spawnData is just a wrapper class I’m using to hold a bunch of data which I then access at a later date when I parse spawnPattern.

The problem herein lies: I need to be able to edit the individual elements of spawnData in the Inspector. The only way I’ve been able to make this happen is by setting spawnData as a class to System.Serializable inside the SpawnPattern class. This has the problem however that after I set up a full spawnPattern (say of 6 enemies) and then hit play to test it, the spawn pattern is now empty after I finish testing.

How can I get the changes to stick in the Inspector?

Updated my post with the solution. Thanks everyone!