I create a struct, let's call it Example.
Here it is :
[System.Serializable]
public struct Example
{
public enum Categories {example, test}
[SerializeField] private Categories lineCategory ;
public Categories _lineCategory { get {return lineCategory;} }
[SerializeField] private Translation[] translations;
public Translation[] _translations { get {return translations;}}
}
And here is the class Translation :
[System.Serializable]
public struct Translation
{
public enum Languages {fr, en}
[SerializeField] private Languages language ;
public Languages _language { get {return language;}}
[TextArea] [SerializeField] private string line ;
public string _line { get {return line;}}
}
When I'm using it with unity, there are 0 problems, the System.Serializable make it easy to use.
But, for practical reason, I want to create one with code.
Here is an idea of what I want to create :
private Example test = new Example {
lineCategory = Example.Categories.test,
lines = new Translation {
{language = Languages.fr,
line = "test ligne"},
{language = Languages.en,
line = "test line"},
}
}
Obviously it doesn't work, first because of private / public but, there are more problems and I really can't figure them.
I'm showing here only a small part of my problem, because I would like to create a really big struct for all the translations in my game so there will be more than just one lines but this way you'll understand the problem I think.
Does someone know how to create a new Example() in a good way ?