« first day (3741 days earlier)      last day (1280 days later) » 

1:28 PM
Sooo... MVC pattern in unity... we have a model ( data structure ), a view ( UI Object/GameObject ) and a controller ( The logic of the view, combines data structure and the view itself, Monobehaviour )... Would we attach the controller to the UI object/GameObject itself ( So each UI object could have a different controller ), or would we have one controller instead ? Does this matter at all ?
 
in mvc the controller is just the logic that acts on the view and model
as you have no logic in either view nor model, you will need a controller for each UI object technically
or have a controller that produces the UI objects
 
Thanks :) Well if thats the case... we could really attach one controller for each UI object. So we would simply need to pass in the data. And probably a controller that acts as a screen to spawn in the other UI objects. Alright... now i only need to understand the difference between MVC and MVVM
 
in webdev you usually create one controller per logical-area, which is usually denoted by a path. So having one controller per UI object makes a certain sense
MVVM is a more complicated version of MVC, where the VM (ViewModel) acts as the interface between VIEW and MODEL instead, and defines all methods that write data from MODEL to VIEW. So your usecase will likely be MVVM
 
Thanks, hmmm... so the viewmodel is basically the controller here... but it defines all available methods ? ^^ I probably should look at some example code to understand the difference :)
I just read that MVVM uses databinding... thats interessting
 
1:47 PM
not really, the controller usually does pathing, that is deciding how you get somewhere. The ViewModel doesn't path, it really just maps values (and does fancy conversions and such, e.g. transform your string "A, red" into a label that reads "A" and is red..). The pathing in MVVC happens in the view normally
So in MVC everything that happens on a view would that modifies data would trigger a call to a controller (via pathing). While in MVVM you propagate a modified-event that the VM handles
 
Ah... ok... so the key difference is the way its wired. MVC = Controller handles the data inseration / MVVM = View inserts data into the UI, ViewModel uses Events to tell the view what to insert
 
about that, yeah
basically the logic behind the buttonclick is handled in the VM
and in mvc via controller
 
2:08 PM
As a ui newbie... i would say that this is a minor difference. But i read that MVVM is much cleaner because it seperates the business logic much better
 
2:19 PM
Damn... now i also need to convert my ECS datastructure into a seperate UI datastructure somewhere
 
my recommendation is to write code as you feel it should be written, then see if a pattern can be applied - rather than looking for patterns first and then shoehorning your code into one
 
Thanks, i need some sort of pattern for my UI... currently its just very bad wired. Probably i could just skip the "Model" part of the MVC/MVVM and replace it via the ECS entity itself, basically its also a poco
So the ViewModel listens for data changes, right ? So it could just listen for reactive system events ( Entity added, data changed, removed )... that would fit perfectly
 
2:48 PM
data changes AND ui changes
it does the work in both directions
in theory
 
Ah ok... ui changes = input, click events ? ^^
 
for example
or somebody entering text into a textfield
 
3:09 PM
Thanks ! This is getting interessting :) I created my first MVVM approach, one ItemEntryView ( Script that references to the UI elements we need ), one ItemEntryModel ( Basically a ECS Entity reference ), one ItemEntryViewModel ( Uses ItemEntryView to fill in data from the ECS ) hatebin.com/fznkegkdyq
Excited if it works correctly
I skipped the databinding part ^^ i saw there some libraries for unity with data binding, but ill leave this for now
 
 
4 hours later…
user92578
7:23 PM
6k woop!
 
7:54 PM
@Tyyppi_77 Congratulations!
 
8:51 PM
0
Q: Intersection of thick line with a grid

Mr. SmithThere is a popular paper, and numerous examples, on how to efficiently perform collision detection for a line with a grid. However, I'm drawing up blanks on how to do the same thing but with a line that has thickness. In my game, I'm considering adding projectiles that are not infinitly thin (for...

 

« first day (3741 days earlier)      last day (1280 days later) »