Can GUI controls be created from a database?

I am creating a restaurant style game where the user will click on small cards at the top of the screen in order to create a certain recipe. (similiar to the plant icons in Plants vs Zombies). So for example they might have a card that has a water icon and another that has pasta. They click the water icon and it fills a pot with water, they click the pasta icon and it puts it in the pot and starts cooking.

So for each recipe the ingredients would usually be different, having never used the Unity GUI system before, is it possible to drive all of this information (the icons, their order, their actions when clicked) from a database? Would the built in GUI system be appropriate for this or would something custom be required? The advantage would be that new recipies could be added without needing to change any game coding, but by just updating the database.

If anyone has any experience with this, your thoughts would be greatly appreciated.

Thank-you

Sure, that could work. Just try not to do anything from the OnGUI function, but do all calculations in the Update function and then display the results through the OnGUI. One small game I made a while back actually loads data into the GUI based on what your mouse is over, it’s rather easy.

It’s definitely possible, but it might be just as easy to store all your info in configuration files (text files) that you import as TextAssets.

I use configuration files with pipe delimited data to initialize my project with editor scripts. If you use a database you’ll have to go through a similar process parsing the output of server side scripts (as far as I know). There are probably many different ways to approach this, however.

Here’s a link to a question about parsing a text file:

parsing csv file - Questions & Answers - Unity Discussions