- Home /
Several Questions about MVC pattern
Recently I read several articles about MVC pattern, and I was confused about some concepts 1. If Model is only for storing data, is there a good way to initialize data without using the Unity inspector?
For some of the articles I read, they say Model should not inherit Monobehaviour for portability, only View should be attached to game objects as a component. Based on my current knowledge level, the only way I can come up with for initializing Model's data is reading from a txt, json or excel file, and I wonder if there is a more commonly used way to do that.
2. Since Controller is the bridge between Model and View, can View keep a reference of Controller?
In some example codes, I saw a Controller usually keep the readonly reference of Model and View, but what if View needs to get some information in Controller or Model? For example, assume I have a Move() method in View (which simply move the player around), and it takes the input axis, but the "speed" attribute is stored in Model, so I guess I can write a GetNextFramePosition() method in Controller which calculates the position in next frame by taking the input from View and the "speed" attribute from Model. However, I'm not sure if it is nice for View to keep a reference of Controller.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How do I dynamically generate scenes? 5 Answers
Are there consequences to exceeding Serialization Depth? 0 Answers