Hello guys, i am working on an interior design app. I need to create a gui menu which reads categories and subcategories from a DB and populate the DB with the meshes loaded on the DB. I can't figure out how to create a dynamic gui which expands reading the database. Eg: main categories: Lights | Tables | Libraries | Accessories Subcat of Lights: Table lights | Wall Lights | Portable Lights Objects in Table Lights: Mesh1 | Mesh2 | Mesh3 The Database creation is not a problem, i don't know where to start in unity to populate the dynamic gui menu. Anyone has some tips for a starting point, or dealt with a similar problem? Thanks
My advice is to separate UI and database. Add a class structure wich will reflect your GUI items and pupulate it from database. Then create a class for drawing GUI elements, and draw them depends on data and state of corresponded class.
Here is example of such architecture: Code (csharp): ///Example menu class Menu { public string Header {get;set;} public string StartButtons {get;set;} /// it also could be an array of buttons ;-) public string CloseButton {get;set;} public bool IsActive {get;set;} /// state of GUI element (shown or not) } class MyGUI : MonoBehaviour { Menu menu = new Menu; void Start() { /// Populate GUI elements here: menu = MySuperDatabase_GUIRepository.GetMenu("Menu version 1"); /// Class that responsible for downloading menu content from DB menu.IsActive; /// show menu } void OnGUI() { if(menu.IsActive) { GUILayout.Label(menu.Header); if(GUILayout.Button(menu.StartButton)) ;/// TODO if(GUILayout.Button(menu.CloseButton)) menu.IsActive = false; } } }