Improve Your Unity Code with MVC/MVP Architectural Patterns

Поделиться
HTML-код
  • Опубликовано: 26 дек 2024

Комментарии •

  • @git-amend
    @git-amend  11 месяцев назад +18

    Hey everyone, hope you find this video helpful in understanding Separation of Concerns with the MVC or MVP patterns. Code links are in the description. Let me know if you have more questions and if we need a 3rd episode on this topic!

  • @orbalmas7539
    @orbalmas7539 8 месяцев назад +7

    First thing, great video!
    I have been working as an Android Developer for 7 years now, implementing MVC, MVP and then MVVM in all my projects.
    One note about the video, It is not best practice to tightly couple the Controller to the view, as then you lose what you wanted, which is separation of concerns.
    In order to achieve that, you could use the Observer pattern and remove the dependency of the view from the controller.
    This is desirable because it makes the code more testable, and you get the extra benefit that if you are going to make changes to your view, no changes are needed to your controller as it is truly separated.
    I love your videos. I started my long-standing dream of game development and have been glued to all your videos since. Keep up the great work! 👍

  • @carlwong1919
    @carlwong1919 11 месяцев назад +24

    Finally found a tutorial that not only talks about the three core MVC components, but also shows how to create and connect them. Really helpful.

    • @git-amend
      @git-amend  11 месяцев назад +2

      Right on! Glad to hear that!

  • @gleefuluv
    @gleefuluv Месяц назад +1

    This is hands down the best gamedev/unity channel I've ever seen. Straight to the point, good practices, your own game examples for clips, nice explanations with graphics/diagrams, great voice with nice pacing, no BS memes/clickbait, no selfy video on the corner blocking views. Relatively short, but concise, no fluff. Excellent, excellent teacher.

    • @git-amend
      @git-amend  Месяц назад +1

      Thank you for the kind words!

  • @Hersatz
    @Hersatz 11 месяцев назад +14

    Great explanation and contextualization, as always.
    MVC, MVP, and MVVM are staples of proper UI architecture in video games.
    I'm glad that someone is finally taking the time to show people an actual implementation of one of them.

    • @git-amend
      @git-amend  11 месяцев назад

      Well said! Thanks for the comment!

  • @jvizcode4845
    @jvizcode4845 11 месяцев назад +5

    Your videos work for me as glue. Making all that I have learned come together. Now I have a new perspective and that's a big help, more than I could ask. Thank you very much.

    • @git-amend
      @git-amend  11 месяцев назад +1

      You are so welcome!

  • @징어오-t6v
    @징어오-t6v 11 дней назад

    I didn't know about UI because I wasn't interested in it, but after watching this video, I realized for the first time that there was such deep content. Kudos to you!!!!

  • @IdealIdleIncremental
    @IdealIdleIncremental 11 месяцев назад +6

    Thank you for this super-useful video! Every time I see an update on your channel, I immediately know that there's a new video worth watching. Please keep up the good work!

    • @git-amend
      @git-amend  11 месяцев назад

      You're very welcome!

  • @halivudestevez2
    @halivudestevez2 11 месяцев назад +3

    finally someone is using diagrams for teaching and telling. The diagram at 4:00 makes many things clear.

    • @git-amend
      @git-amend  11 месяцев назад +1

      Good to hear!

  • @k3ln
    @k3ln 11 месяцев назад +1

    you're the greatest man, I needed this so much! I've been doing this all the time in my past years on web development, it didn't occur to me to try something similar for game development, this is great, thanks

    • @git-amend
      @git-amend  11 месяцев назад +1

      You're very welcome!

  • @jordanbarker803
    @jordanbarker803 11 месяцев назад

    Incredibly well done. The way you showed the diagram first, explained it, then jumped back and forth between code and diagram to show which part was being implemented was really helpful. Just found your channel, looking forward to checking out the rest of your content. Keep up the great work!

    • @git-amend
      @git-amend  11 месяцев назад

      Thank you very much!

  • @Oguzhan-l2z
    @Oguzhan-l2z 9 месяцев назад

    Loved the Unity Game Architecture series! Suggesting a playlist reorder for better flow: Start with 'SIMPLE Tip,' then 'Improve Your Unity Code with MVC/MVP,' and end with 'Learn Unit Testing.' Amazing work and best wishes!

    • @git-amend
      @git-amend  9 месяцев назад

      Thanks! More to come!

  • @TheArghnono
    @TheArghnono 11 месяцев назад +1

    Another great video! Glad to see there is at least one Unity youtuber who writes modern code.

    • @git-amend
      @git-amend  11 месяцев назад +1

      Thanks for the kind words!

  • @VladaPersonal
    @VladaPersonal 11 месяцев назад +3

    It is rare to have unity tutorials that go this deep. But this is exactly what I need to get to the next level! Thanks alot!
    I just feel like having the videos in a series might be a good idea? When I watch this video there are some things I missed and having a structure/order in which to go through the videos would be great! Even if the reality is to watch all of them, episode number for example would indicate it well. But I understand the title has other needs as well...

    • @git-amend
      @git-amend  11 месяцев назад +4

      Thanks for the comment! Unfortunately having an episode number on RUclips is a bit problematic because new viewers don't want to jump in if they feel like they need to commit to watching a bunch of earlier content, which makes it really hard to grow the channel. While I try to make every video stand on its own, if I reference something from an earlier video - like the Event Bus - I try to include a card in the video with the link. If you really want to watch it all, start with the Patterns playlist and then the Architecture one after that. These playlists are in the order the videos were made.

  • @baselpro5228
    @baselpro5228 11 месяцев назад +2

    Your videos are fantastic keep it up 🙌

    • @git-amend
      @git-amend  11 месяцев назад +1

      Thank you! Will do!

  • @junaidywijaya6413
    @junaidywijaya6413 11 месяцев назад

    This is something I've heard for quite a while and seen a bit of it but never understand what it really is and how to really implement it, thank you for this video to make me understand a bit of it, might need to watch it couple times so i can really grasp the true idea, but as always a great video from Adam.. keep it up man, i know u will be big 😄

  • @antijulius
    @antijulius 11 месяцев назад

    Seriously, thank you so much for putting out this level of content.

  • @echoness_
    @echoness_ 11 месяцев назад +2

    Thank you for the detailed walkthrough. It would be awesome if you can introduce how to structure MVVM and data binding in Unity.

    • @git-amend
      @git-amend  11 месяцев назад +4

      Thank you - actually data binding is on my list, I'll get to that one soon!

  • @Broudy001
    @Broudy001 11 месяцев назад +3

    Another great video, I need to implement it to get my head around it though.
    I'd be interested to see you go through a set of tutorials where you build out a game using the patterns, like a vertical slice of a game using the patterns. Would be a huge amount of work though I'd expect, and I would assume you already have plenty on your plate :D. Could be a paid course, I'd definitely pay for it.

    • @git-amend
      @git-amend  11 месяцев назад +1

      Thanks for the comment! One of these days I'll take that course suggestion on, just need a month off work!

    • @Broudy001
      @Broudy001 11 месяцев назад

      @@git-amendI imagine it would be a lot of work to setup. Either way I've learnt a ton from your videos , and look forward to every new one that comes out

    • @mongreldesigns9195
      @mongreldesigns9195 11 месяцев назад

      +1 for a larger paid course, your videos are gold.

  • @mhouney
    @mhouney 6 месяцев назад +1

    I hopr some people can learn from my mistake: I used the Event-Bus inside a system, which lead to a confjsing structure inside a mvp system. I learned that the Event-Bus is very nice for communicating between different mvp systems. Inside a system I used then simple public Actions on my view that forwards the events to the presenter and the presenter decodes what to do.
    I dont know if this is the best approach, but it worked pretty well for me.

    • @mhouney
      @mhouney 6 месяцев назад +1

      Another question: Would it be a good idea to have multiple views? (E. .g with 3 different interfaces) Currently I solve this by using 1 view that contains other "views" woth SerializeField.

  • @ronnistrm1167
    @ronnistrm1167 11 месяцев назад +1

    Through out the years I have been bitching to my fellow software developer friends on how shitty every youtuber is when it comes to programming in unity. (from the perspective of a programmer)
    I will like to thank you for spending time figuring out how to utilize great patterns and concept from the world of programming inside unity.
    Working as professional software developer I know and work with a lot the patterns you show.
    But I never really have the time to figure out how use it probably in unity.
    Thank you for saving us time on "inventing the wheel"
    Keep up the good work!

    • @git-amend
      @git-amend  11 месяцев назад

      That is very high praise, thank you very much. More to come!

  • @rehrocks
    @rehrocks 11 месяцев назад

    Nice video as always, and I've already started the MVC course on Udemy to learn more about it.

    • @git-amend
      @git-amend  11 месяцев назад

      Great to hear!

  • @MaxVinopalDev
    @MaxVinopalDev 11 месяцев назад +1

    Great content as always, said it before, but it is so great to have these intermediate videos in sea of for-beginner stuff! One question - in a game like Dragon age, where player can switch between different characters, would you have the MVC/MVP combo for each of the characters, or would you have just one and build the switching logic inside? Having it for each of the characters makes more sense for me, but id like to know your perspecitve :) Thanks!

    • @git-amend
      @git-amend  11 месяцев назад +2

      Thanks! That's an interesting question. I think for a Dragon Age style I can see how having one for each character would make sense. Just be careful of any state that needs to be shared between them and take that into account somehow if necessary in case you have any data they all need access to or if they need to communicate with each other.

    • @MaxVinopalDev
      @MaxVinopalDev 11 месяцев назад

      @@git-amend Will keep that in mind, thanks!

  • @Cloud-Yo
    @Cloud-Yo 10 месяцев назад

    I was wondering if you were considering doing a video on developing features for a game w TTD? awesome stuff as always!

    • @git-amend
      @git-amend  10 месяцев назад +1

      Maybe... but game devs don't like tests so much...

    • @Cloud-Yo
      @Cloud-Yo 10 месяцев назад +1

      @@git-amend I certainly dont, and I have studied them some, but a lot of studios hiring seem to love to post them in the requirements for positions. In any case, I guess I hope you can get around to it, but its fine if not :)

  • @uhhmir
    @uhhmir 11 месяцев назад

    ObservableList? i can feel a reactive programming episode coming😳😳

    • @git-amend
      @git-amend  11 месяцев назад

      Haha maybe so!

  • @MarushiaDark316
    @MarushiaDark316 11 месяцев назад +3

    I've always found the terminology around MCV to be rather unintuitive, but if I understand correctly, it's basically just saying to keep your Logic, Data, and Visuals all separate from each other.

    • @git-amend
      @git-amend  11 месяцев назад +2

      Yeah, that's pretty much it.

  • @abraiyan7984
    @abraiyan7984 11 месяцев назад

    Lets goooo! Thanks for this.

  • @techdave99
    @techdave99 11 месяцев назад

    Another video worth getting up early to watch. I thought that mvc/p would be hard to implement in Unity. Looks like it is worth using.

    • @git-amend
      @git-amend  11 месяцев назад

      Thanks for watching! You must be west coast like me.

    • @techdave99
      @techdave99 11 месяцев назад

      @@git-amendYes I am. I am on Vancouver Island. For some reason I thought you were on the east coast.

    • @git-amend
      @git-amend  11 месяцев назад +1

      Nice, I lived in Sidney for about a year back in 2019.

    • @nuin99
      @nuin99 11 месяцев назад

      ​@@techdave99 fellow vancouver island fella, you doing/did global game jam?

    • @techdave99
      @techdave99 11 месяцев назад

      @@nuin99 no. i'm not really a jammer. Did you? what did you make?

  • @kr1s85
    @kr1s85 11 месяцев назад +1

    Coming from Java Enterprise development, it's nice to see examples of how to implement those patterns in Unity. Great work! ⚔⚔⚔⚔ Where would you trigger SFX cues? Would you build an observer that listens to the Event Bus or inside the view?

    • @git-amend
      @git-amend  11 месяцев назад +2

      Thanks! My first thought was just to say, yeah I'd have a separate observer on the Bus. However, maybe not for all sfx. If it was UI sfx, that really is part of the View I would think, like mouse click sounds etc, and doesn't have to be played in 3D space either. And, potentially you could also have sfx be played directly by the ability command with AudioSource.PlayClipAtPoint which creates an audio source at any point in the world. I guess in the end, it really depends... but I think for most, I would raise an event onto the bus and let another system handle it.

  • @techdave99
    @techdave99 11 месяцев назад +1

    @git-amend There is a rogue if statement in the posting of the ability mvc system. In the gist line 145. The if statement doesn't belong to anything (not in a method) and throws an error. Also, AbilityCommand is not defined. Will post this in discord too.

    • @git-amend
      @git-amend  11 месяцев назад

      Alright thanks, will look at it

  • @Patricebrouh
    @Patricebrouh 10 месяцев назад +1

    Hi! Great video. I am also interested in PC movement. I notice that when PC jumps, camera doesn't follow. How do you achieve it? Thanks

    • @git-amend
      @git-amend  10 месяцев назад +1

      Thanks, and great question. One day I'll make a longer video about building a custom player controller like this.
      Basically, under the top most game object I have two children - one branch for the model and another branch for camera items. In the camera branch there is a 'camera target' game object which the camera aims at. So if something in the model branch moves, nothing in the camera branch moves, but the entire player moves them all. So essentially I'm achieving this by separating the model from the camera, but they both have the same parent.

    • @Patricebrouh
      @Patricebrouh 10 месяцев назад

      @@git-amend Thank you for your answer. It helps me so much. I look forward to watching this video about player controller 🙏🏽

    • @attevirginie96
      @attevirginie96 9 месяцев назад

      I am interested in this functonnality too.

  • @DaggerCode
    @DaggerCode 19 дней назад

    Great video!
    What are your thoughts on topics like "MVC is not used in games", adds to overhead, relies on data-binding... I really like this pattern and you explained it really good! But can't avoid feeling like maybe this isn't the best pattern for game dev? Do you know what companies architectural pattern usually uses? (avoiding custom architectures, obviously).
    Would appreciate a brief explanation.
    Continue doing videos like that, really good job!

  • @junaidywijaya6413
    @junaidywijaya6413 11 месяцев назад +1

    Hey Adam, i have a question and maybe an idea, so whenever i want to create a new feature often i don't really know how many modules I'm gonna need and how deep it's going to be, so do you have tips on planning it like your flow chart.. thanks in advance

    • @git-amend
      @git-amend  11 месяцев назад +3

      What I would do is start with a skeleton UML diagram so you can see it visually. A tool like excalidraw.com/ is very useful. Draw out your first draft and draw lines where you see dependencies - make sure none of them form a loop! Once you being coding, don't be afraid to refactor. Then go back to your diagram and update it, so you make sure it still makes sense to you. Just practice and never stop learning new things, and you'll get better and better at it. Your best tool is going to be experience and knowledge.
      Have a read through the object and class diagrams sections of this page:
      www.c-sharpcorner.com/UploadFile/nipuntomar/uml-diagrams-part-1/

    • @junaidywijaya6413
      @junaidywijaya6413 10 месяцев назад

      @@git-amend thank you will check it for sure 👍

  • @arjanb7158
    @arjanb7158 11 месяцев назад

    Great stuff, thanks! The past two videos made me wonder a couple things:
    * What sort of gameplay stuff would you still do on MonoBehaviours? Do you delegate collision events and Transform-changes to non-Monobehaviours, too? (As with the Update(deltaTime) function.)
    * I can see dependencies being injected in the non-MonoBehaviours, but would you still use the editor to specify dependencies for MonoBehaviours?
    * Would all your MonoBehaviours depend on concrete classes, since the editor doesn't serialize interfaces? What does this mean for mocking in your tests?

    • @git-amend
      @git-amend  11 месяцев назад

      You can still make use of methods like OnTriggerEnter, Update, FixedUpdate etc, but many progammers will gravitate more and more towards encapsulating the logic associated with these things into pure C# classes that can be easily tested and swapped. As far as MonoBehaviours depending on concrete types, often yes this is unfortunately the case. However, I have another video planned regarding serializing Types which you will probably find interesting, in a few weeks or so. You can also use Odin to reference interfaces through the Inspector.

  • @TheKarchi
    @TheKarchi 10 месяцев назад

    Great tutorial! Do you think you could use a bigger font in the IDE in your future videos to make the code easier to read when watching on mobile?

  • @zeggxr1539
    @zeggxr1539 3 месяца назад

    When i include a future in my game i think about MVP/MVC if that feature needs to be implemented MVP/MVC, how to decide that correctly.

  • @shayshay8295
    @shayshay8295 2 месяца назад

    As a software engineer with few years of experience I can say that your channel could be very useful, thanks! What is your resume?

  • @Kingdomax
    @Kingdomax 11 месяцев назад

    Thanks for the demonstration. I wonder what other use cases can be used with MVC/MVP pattern(apart from UI system).

    • @git-amend
      @git-amend  11 месяцев назад +1

      You're welcome. In that demo scene I actually also have the score system and the player controller implemented as MVC, but the ability system seemed to be the best one to show for the video since the view was more involved.

  • @mehmedcavas3069
    @mehmedcavas3069 11 месяцев назад

    Yess part 2. can you also make a video how UI should me made with old UI system. I mean how to handle multiple canvases to decrease rerender the whole canvas or even make a separated UI scene

    • @git-amend
      @git-amend  11 месяцев назад +2

      Not a bad idea, I'll put that on the list. There have been a lot of requests about UI Toolkit as well, but I think most people are still on the old system.

  • @claudiogallardo6383
    @claudiogallardo6383 11 месяцев назад

    Great video as always! I am a seosoned Spring MVC developer and this explanation makes Unity so much approchable for me. Following your videos there is so much code and utilities I see myself using in my test after test projects. Would you recommend me to create my own unity packages with the systems you have explained? I guess the EventBuss would be tricky due to the assambly part...

    • @git-amend
      @git-amend  11 месяцев назад +1

      Thanks! I think you could create packages if you wanted, it can be useful sometimes. Just remember that if you are creating an embeddable package it becomes immutable. I was thinking about making a video about this at some point. The Unity documentation is actually pretty good: docs.unity3d.com/Manual/CustomPackages.html
      and I recently moved the Unity-Utils repo to be a package that you can install from the git, you could look at that as an example.

    • @claudiogallardo6383
      @claudiogallardo6383 11 месяцев назад

      @@git-amend gr8! thanks

  • @Kritikkkk
    @Kritikkkk 9 месяцев назад

    Thanks for the video, it is a rare occasion to see such topics about MVC and Unity. Although MV* patterns (as well as Zenject and UniRx) are considered standard in post soviet countries (and I thought that it is caused by the fact that many devlopers came to game development having a enterprise app background where such features are a must). I am wondering how popular are MV* patterns in development studios? What other techniques are considered standard in your opinion? Also the topic of separation of concerns is very interesting to me, and is there any other methods like MV*?( as I understand that it isn't supposed to fit all scenarios)

    • @git-amend
      @git-amend  9 месяцев назад +1

      To be honest, not too many people apply these kinds of patterns to their Unity games, but I would also say that MVVM could be included. But it's application might be as simple as separation of concerns with data binding. I think data binding will be the topic of a future video.

  • @ekekw930
    @ekekw930 11 месяцев назад

    Awesome stuff!!

  • @DadMakesGamez
    @DadMakesGamez 11 месяцев назад

    Great episode, it explains the topic very well, it’s pleasant to listen and watch. Being on the architectural patterns, can you say what you think about ECS? At first glance, it has the same advantages as MVC (encapsulation, data separation from behavior, etc.) but with contiguous memory usage and better performance. I would love to know your opinion.

    • @git-amend
      @git-amend  11 месяцев назад +3

      Thanks for the comment, I appreciate that. ECS is very powerful, and I've been asked to talk about it many times - but I also wonder why. Do people struggle with it because it's a different (and more complex) paradigm, or possibly because Unity dragged it's feet in this area for so long that people lost interest - or has nobody been able to explain it in a manner that makes it approachable. I suspect it's the first reason. I wonder if showing a hybrid solution might get people interested. Maybe I'll read through some of the comments on a some newer content about it and figure out what's holding people back, might make a good video.
      What do you think holds people back the most from using ECS?

    • @DadMakesGamez
      @DadMakesGamez 11 месяцев назад

      It seems to me that for a long time, the problem was the instability and backward incompatibility between versions. Looking at versions 0.5 and 1.0, it’s like a night and day (though in a good way). I even considered using svelto.ecs instead of Unity’s for quite a while.

      But yes, I agree with you that the main problem is the paradigm shift in thinking.

  • @sandrawiedel5411
    @sandrawiedel5411 11 месяцев назад

    Thanks for excellent tutorial .. like always. May i ask, what software do you use for you diagrams? They look really nice!

    • @git-amend
      @git-amend  11 месяцев назад

      You’re welcome! Right now I use SketchWow but I’m going to try Excalidraw this week

  • @aleksapetrovic7088
    @aleksapetrovic7088 8 месяцев назад

    How/where would you execute the abilities logic? What I've often encountered is that I have spells/abilities/whatever which highly vary in the things that they do. My first assumption is to have an abstract method where each concrete implementation would handle the logic in their own way. The issue I've encountered with that many times is that they often require different data passed onto them to perform the necessary logic, while the abstract definition clearly defines which parameters must be passed.
    It's a really annoying thing I've never managed to solve properly..

    • @git-amend
      @git-amend  8 месяцев назад +1

      Typically I use the Command pattern for this. Each command is different, but can employ it's own Strategies for targeting, effects and so on.

  • @omeryilmaz1021
    @omeryilmaz1021 7 месяцев назад

    is there any utility folder or collection that I can find of yours which includes features like CountDownTimer, observablelist and etc.

    • @git-amend
      @git-amend  7 месяцев назад

      A lot of the small helpers are just in Gists - you can find all of that here: gist.githubusercontent.com/adammyhre/
      Otherwise, check the Unity Utility repository here: github.com/adammyhre/Unity-Utils

    • @omeryilmaz1021
      @omeryilmaz1021 7 месяцев назад

      @@git-amend thank you very much I will work on them

  • @ekekw930
    @ekekw930 11 месяцев назад

    How did you create your UI? Is it an asset pack? Im checking for some good looking globes I can use and these look amazing

    • @git-amend
      @git-amend  11 месяцев назад +1

      That one is from the store - assetstore.unity.com/packages/2d/gui/cartoon-fantasy-gui-74743
      The globes aren't animated though, so I would probably replace them with either ones from Moon Tribe:
      assetstore.unity.com/packages/2d/gui/icons/ultimate-health-bar-collection-178690
      or Kronnect: assetstore.unity.com/packages/vfx/shaders/liquid-volume-pro-2-129967

  • @chicho9238
    @chicho9238 9 месяцев назад

    Hey, I've been following your awesome channel for some time and I've been able to really capitalize on all the programming design knowledge you share. That being said, I'm having some trouble applying MVP (or rather framing it) for my current project:
    I have some purchaseable upgrades, each of which I want to put on a button on a scrollable list with its name on the button. When you hover over one of these an info window appears right next and inlcudes the name of the upgrade (again), its cost and a description. When you click the upgrade button it tries to spend your resources (which I've got in an ScriptableObject) and purchases and applies the associated upgrade.
    Though, I've tried a couple of times and consulted sources (as you said in the video, everyone puts a twist on the model), I'm not sure if I'm extracting the right things that each part of the architecture should expose.
    My thoughts are that: View is an observable and a "settable" that gets passed to the Presenter (either if view creates it or not); Model is again an observable for when it changes and a settable; Presenter gets the Model and View injected by the constructor and subscribes to view events and model events, additionally it exposes methods to take input from other systems.
    In my tries to model the architecture for my project I've tried to abstract these roles to reutilize them, because you can see it somewhat a complex list of views to update and handle correctly. But it just doesn't click that much.

    • @git-amend
      @git-amend  9 месяцев назад +1

      It's clear you're putting a lot of thought into applying the MVP pattern to your project. It's important to remember that these architectural patterns lare fundamentally about separation of concerns. For your upgrades and scrollable list of buttons, consider the following:
      View: The View should be as dumb as possible - it displays what the Presenter tells it to and signals the Presenter about user actions (e.g., hovering over or clicking a button). The View doesn't know what happens when a button is clicked; it just knows to inform the Presenter of the click.
      Presenter: Receives inputs from the View (e.g., a button click) and decides what to do with them. It might check if the player has enough resources for the upgrade, update the Model accordingly, and then tell the View to display a success or failure message. The Presenter should be the one knowing which View to update and how, based on interactions and data changes.
      Model: Should notify the Presenter (not the View directly) when data changes, so the Presenter can update the View. Your ScriptableObject that tracks resources could be part of the Model.
      Your thoughts on making the View and Model observable and "settable" and having the Presenter manage interactions and updates are on the right track. The flexibility of MVP comes from the ability to abstract and reuse the Presenter and View logic for different parts of your UI, not from strict adherence to rules about what each component does.
      In practice, the boundaries can blur, especially in complex or interactive UIs. The key is to keep the core idea of separation of concerns in mind rather than sticking too rigidly to definitions. For instance, if it makes more sense for a complex interactive element to handle some of its own logic for performance or user experience reasons, that's okay as long as the overall structure remains clear and maintainable.
      Finally, it's perfectly normal to iterate on your architectural design as your project evolves. Sometimes, you only find the right abstraction level or component responsibilities through trial and error. Keep experimenting, and adjust the roles of Model, View, and Presenter as needed to best fit your project's needs.

  • @BrontoKroxig
    @BrontoKroxig 11 месяцев назад

    I'm really curious about which software are you using to draw your diagrams :O

    • @git-amend
      @git-amend  11 месяцев назад +1

      I have been using SketchWow, but I think I might try Excalidraw for the next video

  • @KuroUsagi1010
    @KuroUsagi1010 8 месяцев назад

    Hello, the "Key" and the "Keyboard" in the AbilityButton class. from which namespace was it? it's not appearing on my Visual Studio. and when i tried the System.Windows.Input. the Keyboard class doesn't know about the "current" . sorry about the newbie question

    • @git-amend
      @git-amend  8 месяцев назад

      docs.unity3d.com/Packages/com.unity.inputsystem@1.8/api/UnityEngine.InputSystem.Key.html
      The Key enum is from Unity's New Input System.

    • @KuroUsagi1010
      @KuroUsagi1010 8 месяцев назад

      @@git-amend Oh thanks! I'll check later if it's available in Unity 2022.2f

  • @PredatorPeyami
    @PredatorPeyami 4 дня назад

    sorry is this continuation of series? if yes i was not able to find other parts.

    • @git-amend
      @git-amend  4 дня назад +1

      It is not part of a series.

  • @mitchellg8469
    @mitchellg8469 10 месяцев назад

    Thanks, this has been really helpful and detailed! If I want to change what is being presented on the UI depending on what the player has selected, how would you go about that. Should the model be changed depending on the selection? Also if the data is to be changed at runtime I would guess I would probably not use a scriptable object and just use a normal c# class? For my use case I want to have selectable towns that have stats that change during play. Thanks again!

    • @git-amend
      @git-amend  10 месяцев назад

      I would add functionality to the Controller so that it can change your model at runtime. The data could still be in scriptable objects, just pass the SO to the Model from the Controller. The Model can then change from using one SO to the new one for it's data. Remember that the Model isn't necessarily the same as data that you want to persist - but you can use it to read and write to a scriptable object.

  • @krishx007
    @krishx007 11 месяцев назад +1

    Thanks for saying that there is something called "Over engineering". 😅🙏
    People often conflate separation of concerns with over engineering but there's a big difference
    between writing quality code and adding unnecessary features. Over engineering happens when we lose sight of our actual
    needs and start building for hypothetical situations that may never occur. Quality code is about creating a
    system that's maintainable scalable and understandable.
    ruclips.net/video/v2c589RaiwY/видео.html

    • @git-amend
      @git-amend  11 месяцев назад

      You're welcome! 😀

  • @StratoCatster
    @StratoCatster 10 месяцев назад

    Hello!
    How do you unsubscribe a button if you subscribed a method to it via a lambda?

    • @git-amend
      @git-amend  10 месяцев назад

      You can completely clear out the delegate list of a Unity button's onClick event by setting it to a new instance of the event, like button.onClick = new Button.ButtonClickedEvent();.

  • @damonfedorick
    @damonfedorick 11 месяцев назад

    Nice.

    • @git-amend
      @git-amend  11 месяцев назад +1

      Thank you! Cheers!

    • @damonfedorick
      @damonfedorick 11 месяцев назад

      @@git-amend you don't need to respond if you don't want too, i just want to boost the algorithm.

    • @git-amend
      @git-amend  11 месяцев назад +1

      @@damonfedorick Any you've boosted it again - which I appreciate haha!

  • @JasonLovettGameDev
    @JasonLovettGameDev 11 месяцев назад +1

    Why does this feel like it makes things way more complicated than it has to?

    • @git-amend
      @git-amend  11 месяцев назад +3

      These patterns may appear complex at first, but are effective in handling complexity in larger or evolving projects. While less critical in smaller projects, the principle of Separation of Concerns is still a mark of quality coding in projects of any size.

    • @Briezar
      @Briezar 11 месяцев назад +1

      yeah it doesn't matter if you're making something as simple as Flappy Bird and development would stop there. But once your project gets bigger, something as "simple" as a character controller in a Mario game with logic execution, data, and UI all in 1 MonoBehaviour class will make the class bloat to several thousand lines and heavily coupled. Any change to any element would affect multiple places, and bugs would become hard to track and unexpected.
      It's usually at this point when the programmer starts to think back and wondered if he had structured the code better, constrained the UI to what it does best (visual update) and only allow passing in necessary information for it to update, then he wouldn't have to shuffle up the entire class. Ease of access = ease of bugs. Something wrong with the visual? It's probably in the View class. The character turns left when your press right + down? Probably in the Controller. The character deals too much damage with an ability? Probably the model (stat bug) or controller (math bug).
      At the end of the day, it's all about preferences. If you find it unnecessary for your project, by all means just do it. Your coding style will develop as you code more, and you would gradually understand the important of code engineering.

    • @JasonLovettGameDev
      @JasonLovettGameDev 11 месяцев назад

      I guess I’ve never worked on a project of that size that warrants this yet. I’ve made literally a hundred games without these and it’s been fine, but they were hyper casual games/ indie games. I find if I did this in those games it would have slowed us down quite a lot, but I had to rapidly prototype. So it seems this is really preferable for very large scale projects, in which case I would probably use Unreal anyway lol

    • @Briezar
      @Briezar 11 месяцев назад +5

      @@JasonLovettGameDev the gain isn't in the development speed, it's in the maintenance. Slapping singleton and public static on everything is the fastest way to make games, albeit not very scalable nor maintainable.
      From what I've experienced, anything larger than hyper-casual requires some engineering else it would be a nightmare to fix, update, and add features. Unreal is probably when you wanna make AAA games lol.

    • @JasonLovettGameDev
      @JasonLovettGameDev 11 месяцев назад +1

      Thanks for the replies, I actually agree. Really appreciate the feedback as it helps crystalize it in my mind.@@Briezar

  • @krishx007
    @krishx007 11 месяцев назад

  • @radari7180
    @radari7180 3 месяца назад

    Yo my man just drop a bomb