Hello.
I have a class Cookbookmanager which ineherits from MonoBehaviour.
The Cookbookmanager has a class member CustomRecipe from a custom class which is marked as serializable.
Unfortunately this member does no get serialized, its values are always empty.
Cookbookmanager:
public class CookbookManager: MonoBehaviour
{
private static int _maxRecipes = 16;
[SerializeField]
public CustomRecipe _TEST_RECIPE;
void Start ()
{
//_TEST_RECIPE = new CustomRecipe();
//_TEST_RECIPE.Name = "some name";
Debug.Log("Test-Recipe-Name: " + _TEST_RECIPE.Name);
}
}
CustomRecipe:
[System.Serializable]
public class CustomRecipe
{
private const int _maxIngredients = 6;
[SerializeField]
private string _name;
[SerializeField]
private string _description;
public string Name
{
set { _name = value; }
get { return _name; }
}
}
I started the progamm without the comments of course and the Debug.Log showed the correct recipe name as expected. After that I outcommented the lines where I set the recipe but as it seemed the recipe was not serialized.
Any idea what is going wrong here?
Edit:
The CookbookManager has a partent GameObject which is a singleton and which uses DontDestroyOnLoad(). Can this cause the trouble with the serialization?