I’m having trouble with these classes. Is it not possible to serialize custom types? It was working fine before when I was testing with just the Class1 Class, but after finishing the script with all the Classes I need I can’t seem to serialize these custom types. They all inherit from BaseClass which just holds some variables all the classes share, and are very similar like the examples below. I use a SaveData class that holds the variable info and constructor, and a SaveLoad class that does the serialization saving and loading- both of which had been working without a hitch 'til now. Error occurs while trying to save to path name… If I need to provide more information please inform me. Thank you.
using UnityEngine;
using System.Collections;
[System.Serializable]
public class BaseClass{
public string name;
public int level;
public int NRGcost;
}
[System.Serializable]
public class Class1: BaseClass{
public int bNumb;
public float sTime;
public GameObject[] alls;
public void LevelUp(){
level += 1;
if(level == 2){
NRGcost = 50;
bNumb = 3;
alls = new GameObject[bNumb];
sTime = 8.0f;
}
if(level == 3){
NRGcost = 150;
bNumb = 4;
alls = new GameObject[bNumb];
sTime = 10.0f;
}
}
public Class1(){
NRGcost = 0;
level = 1;
bNumb = 2;
alls = new GameObject[bNumb];
sTime = 6.0f;
name = "Class 1";
}
}
[System.Serializable] //<<Gives error: SerializationException: Type UnityEngine.GameObject is not marked as Serializable.
//>>taking it out gives error : Type Class2 is not marked as Serializable.
//but nothing about Class1.
public class Class2: BaseClass{
public GameObject pow;
public float pTime;
public string pName;
public void LevelUp(){
}
public Class2(){
NRGcost = 0;
level = 1;
pTime = 7.0f;
name = "Pow";
}
}