vendredi 6 décembre 2019

Code design suggestions for Unity event pattern

I'm working with Unity C# for my personal project.

I have seperated Model and View. I want View to be automatically updated when somethings in model change.

So I made an Action object, and added all view-updating functions to it.

The thing is, there is super many fields in model. Adding the event to these fields would be really tedious job, and moreover, a single variable change will cause the whole UI to be updated, which may be a huge waste of perfomance.

But adding individual Action object to each of these fields would be much more tedious job.

All I want is that View is updated when Model is changed, and I think this event pattern is the best choice for my situation.

Are there any suggestions for my code design?

Aucun commentaire:

Enregistrer un commentaire