- Home /
High Level Architecture for Book App
I'm making a book app with 2 page layout prefabs: CoverPagePrefab and StoryPagePrefab.
A PageManager keeps an array of prefab references (one cover page, 20 story pages).
There is only one cover page so I can specialize the CoverPage component on the CoverPagePrefab to load the correct text / image. However, there are 20 story pages so I need a way of initializing them with the correct images/text.
PageManager::PagePrefabArray
Element 0: CoverPagePrefab
Element 1: StoryPagePrefab
Element 2: StoryPagePrefab
Element 3: StoryPagePrefab
...
Element 21:StoryPagePrefab
All text is saved in a localization file with names like "Page1", "Page2", .etc.
Right now I am filling out text programmatically (curPageIdx is 1 so I look up text using key "Page_1"). However, if I were to add a page after the coverpage, say a ThankYouPagePrefab, this would break everything. I want a robust solution that would allow for new pages types to be interspersed into the array without breaking text/images.
Essentially what I am asking is, should I have StoryPagePrefab1, StoryPagePrefab2, .etc which hold initialization data, but all share a reference to StoryPagePrefab for layout of game objects? I'm a newbie to Unity so I am super confused about when and where its appropriate to use prefabs.
Thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220613201518im_/https://answers.unity.com/themes/thub/images/avi.jpg)