I wanna try to make a cookbook app in unity. Right now I am trying to figure out how it all needs to work out, and i hope someone can answer some of my questions.
Im going to have 100+ recipes. What is the best way to storage that amout of data inside unity? Lets say that each recipe has i page with all the information, and in the homepage you can scroll through shortcuts to all the different recipes. How would i store that, in a way that i also can search through the different recipes?
This is a basic question. I really can’t find any links on how to store information like recipes with unity. Do anyone know any tutorials on how to do it?
If you have any thoughts on the topic besides the question, feel more than free to give your thought on how it could workout!
EDIT:
The data needs to be storaged in a way, that you also can sort it by start letter etc.
How would you store it? I think a List would be a good choice for you, but then a question rises - how could a list contain all the information that a recipe might have?
Here, I would suggest writing your own class, that could store this information. For example:
public class Recipe{
public string name;
public List<string> ingredients = new List<String>();
public List<string> GetIngredients(){
return ingredients;
}
}
and then, inside the main script you would have a List of Recipe objects.
public class MainProgram: MonoBehaviour{
public List<Recipe> recipes= new List<Recipe>();
public Recipe GetRecipeByIndex(int index){
return recipes[index];
}
}
This, of course is just a mock-up for anything you’d want to design, but the basis is there. You could use a Dictionary, where the key would be the name of the recipe and so on.
I’ll be leaving the designing of all of this to you, but that’s a really basic way to do such a thing. (There are some other ways to do so, using XML files and storing the information in those, but I myself haven’t had a go at those, so I don’t want to misinform you. But you could try reading up on that as well.)