How can I separate serializable class into its own file?

As the question states, how can I separate my GameData class which is serializable, into its own file?

I tried it and set GameData to be public class, but when I try to instantiate object of it into other class function Unity gives error:

error CS0246: The type or namespace name `GameData' could not be found. Are you missing a using directive or an assembly reference?


[Serializable]
public class GameData
{
	public float experience = Helper.DEFAULT_EXPERIENCE;
	public float score = Helper.DEFAULT_SCORE;
	public float winPercent = Helper.DEFAULT_WIN_PERCENT;
	public int tasksSolved = Helper.DEFAULT_NUM_OF_TASKS_SOLVED;
	public int correct = Helper.DEFAULT_NUM_OF_CORRECT;
	public int difficulty = Helper.DEFAULT_DIFFICULTY;
	
	public bool gameStateDirty = Helper.DEFAULT_GAME_STATE_DIRTY;
	public bool gameIsNormal = Helper.DEFAULT_GAME_IS_NORMAL;
}

Yes I am noob C# programmer but would like little help on the topic.
Thanks.

It sounds like to me you want to read up about “SerializableObject”. Here is an example of using it in a class:

[CreateAssetMenu(fileName = "Item", menuName = "Inventory/Item", order = 1)]
 public class Item : ScriptableObject {
       public string ItemName = "Sword";
       public int ID = 0;
 }

I don’t know exactly why that error was produced because I don’t know what us causing it. I see your “GameData” class, but seeing the code which is attempting to access it would be helpful.