Humble Objects in Unity

Sign up for the Level 2 Game Dev Newsletter: eepurl.com/gGb8eP
MonoBehaviours have the ability to interface directly with Unity's entire ecosystem. That's incredibly powerful, but it comes at a cost. Depending too heavily on MonoBehaviours couples all of your custom logic directly to Unity. This leads to code that is less flexible and harder to test. That's where the Humble Object pattern comes in.
#Unity3D #DesignPatterns #GameDevelopment
The Humble Object pattern is a design pattern that decouples your logic from system level code. In the case of Unity, it let's you keep your code separate from Unity. In this video, Charles teaches Barles how to use Humbe Objects to improve the testability of his Unity code.
Follow along by downloading the example project code at
/ 38990018
Level Design Video: • Level Design & Environ...
👨💻 Join our community: / discord
❤️ Support the channel: / infalliblecode
My Favorite Unity Assets 💯⤵️
1️⃣ Odin Inspector: assetstore.unity.com/packages...
2️⃣ Shapes: assetstore.unity.com/packages...
3️⃣ Easy Save: assetstore.unity.com/packages...
4️⃣ Dialogue System for Unity: assetstore.unity.com/packages...
5️⃣ Editor Console Pro: assetstore.unity.com/packages...
⚡ Learn more about Unity 3D Plus at prf.hn/click/camref:1100l3e8M/...
👋 Contact me directly at charles@infalliblecode.com
* Disclosure: These are affiliate links, which means I'll receive a commission if you use them to make a purchase.

Пікірлер: 92

  • @InfallibleCode
    @InfallibleCode4 жыл бұрын

    📦 Follow along by downloading the example project code at www.patreon.com/posts/38990018

  • @pritheebecareful6895
    @pritheebecareful68954 жыл бұрын

    Alternate title: Schitzophrenic refactoring unity code.

  • @gunesaydin
    @gunesaydin4 жыл бұрын

    Don't you find it weird that Charles always calls when he is needed most. You might need to check your place for listening devices man, someone might be stepping over some boundaries.

  • @johnes2337

    @johnes2337

    3 жыл бұрын

    The Akinator of real life

  • @RosieSapphire

    @RosieSapphire

    3 жыл бұрын

    What if Charles is just a figment of his imagination; what if he was somebody who used to help him with his code all the time, but since his death, he's been hallucinating him still helping him to this day.

  • @Rurek47
    @Rurek473 жыл бұрын

    Charles I'm a professional game developer and your channel is the only one that I've seen that provides the knowledge that can be used to design architecture for a bigger project! Thank you!

  • @TheKr0ckeR
    @TheKr0ckeR Жыл бұрын

    Nowadays, I was trying to find using more "regular c# classes" and i just found out its POCO... I literally couldnt find any information about that around internet with my keywords. But now, I have a full access to these Humble Pattern & Poco keyword.. Thanks a lot Charles, as always, advanced structure video..

  • @TurboMakesGames
    @TurboMakesGames4 жыл бұрын

    Great video -Barles- Charles! I appreciate videos like this because this is already something that I was kindof doing, but this makes it much more clear about when and why I should be using them.

  • @erz3030
    @erz30304 жыл бұрын

    Very well put together as usual Charles and Bharles! This might be something to flesh out on the livestreams as well.

  • @azeews1368
    @azeews13684 жыл бұрын

    Just wanna say your videos are the best I've found on KZread, it's all as clean as it gets :)

  • @NateNorgaard
    @NateNorgaard3 жыл бұрын

    Even though the dialog is kind of cringy... I like it. It actually sets a pretty good example for how to collaborate on code with peers in a healthy way. There's nuance in the relationship between Charles and Barles. Charles doesn't condescend to Barles. Barles isn't a bad or careless programmer who makes nightmare mistakes. When Charles suggests something, Barles can immediately see the value and connects it to principles he already understands - Barles is given dignity as a competent programmer and quick learner who just needs a good teacher/peer for new ideas. I can relate to both of them in different situations. This type of nuance is pretty hard to achieve.

  • @victrolaface
    @victrolaface4 жыл бұрын

    Cant wait for the introduction of Dharles. His shades are so cool.

  • @adriandeveraaa
    @adriandeveraaa4 жыл бұрын

    Wow I havent done this in Unity but I've used this pattern before. I had no idea. Great explanation! subbed. Please do more design patterns!

  • @gabrielkind2970
    @gabrielkind29703 жыл бұрын

    As surreal and deadpan this is, the conversational style was actually really easy to follow. Nice work bruv.

  • @dustypants9326
    @dustypants93264 жыл бұрын

    The important take away is there's a Tavern music playlist on spotify lol

  • @InfallibleCode

    @InfallibleCode

    4 жыл бұрын

    And it’s amazing lol

  • @gilbertobitt3757

    @gilbertobitt3757

    4 жыл бұрын

    I thought I was the only one that start listening it too

  • @rod-abreu

    @rod-abreu

    4 жыл бұрын

    You're not alone guys, I also follow that one Hahahahahahaha. Some other cool stuff to listen to while coding are: Derek and Brandon Fiechter, Adrian Von Ziegler and everything WarCraft related.

  • @zeroone8548
    @zeroone85484 жыл бұрын

    just learned new things Poco , humble objects and humble object pattern thanks Charles

  • @NonaBona
    @NonaBona4 жыл бұрын

    This is high quality content (even the acting!). Great stuff, I'm learning a lot. You definitely deserve more subs!

  • @antonrozum7400
    @antonrozum74004 жыл бұрын

    Dude, I love this type of video!!! Keep it up⚡🔥

  • @CodingWithUnity
    @CodingWithUnity4 жыл бұрын

    Great video as always, regardless of the topic I learn something from your videos.

  • @StackBrains
    @StackBrains3 жыл бұрын

    I am so glad I have found this channel, that's quality content and you are completely different from the "cheap microphone sniffles zombie voice numb 2 hours+ video making" youtubers, and I respect that deeply!

  • @JJZzZzZzZ
    @JJZzZzZzZ3 жыл бұрын

    this design pattern is brilliant!!!

  • @teemuleppa3347
    @teemuleppa33473 жыл бұрын

    i love this whole idea of friend advicing you...just brilliant :)

  • @adamodimattia
    @adamodimattia4 жыл бұрын

    Really nice! Great video!

  • @MaicoRevolucion
    @MaicoRevolucion4 жыл бұрын

    Wow, man. You're awesome. Nice tutorial

  • @KhrisKruel
    @KhrisKruel4 жыл бұрын

    Infectiously optimistic

  • @daslolo

    @daslolo

    3 жыл бұрын

    until Charles starts making soap in the basement

  • @jega3593
    @jega35932 жыл бұрын

    Aweromse video! Thanks!!!

  • @chris.davidoff
    @chris.davidoff4 жыл бұрын

    You should create your own pattern... Call it the Infallible Code Pattern. I'd be pretty convinced to use it just based on the name ;) sweet video, thanks!!

  • @ryanbain225
    @ryanbain2254 жыл бұрын

    Gonna try out the Tavern music channel now

  • @InfallibleCode

    @InfallibleCode

    4 жыл бұрын

    It’s great! I love coding with it on.

  • @adamq272
    @adamq2723 жыл бұрын

    You're really awesome dude.

  • @Pedro5antos_
    @Pedro5antos_3 жыл бұрын

    Awesome!!

  • @phmohmmedalaa174
    @phmohmmedalaa1743 жыл бұрын

    thank you for great tutorials . Can you make a video for shortcuts that's used in vs ? when u used a constructor and making class and for refactoring the code .... and others

  • @matthewbryan6280
    @matthewbryan62803 жыл бұрын

    Really enjoying the format, is a little strange but much easier to digest the information. Quick question: As someone coming from a web-programming background, any suggestions on where to start with Unity?

  • @__ian94__
    @__ian94__4 жыл бұрын

    3:39 The exact same thing I said! 😂

  • @risulkarim5781
    @risulkarim57814 жыл бұрын

    Great content again.. Humble object is my most favorite pattern .. Btw, what font are you using in Rider? It looks great!

  • @InfallibleCode

    @InfallibleCode

    4 жыл бұрын

    Thanks! It's called Victor Mono - rubjo.github.io/victor-mono/

  • @gargoth
    @gargoth3 жыл бұрын

    great video! are you using visual studio?

  • @JohnSmith-ox3gy
    @JohnSmith-ox3gy4 жыл бұрын

    Casually being a bro and a mentor to yourself.

  • @fulongfromthegrave
    @fulongfromthegrave4 жыл бұрын

    Awesome Vid! But lets say you need the Monobehaviour to run 1 or more POCOs methods in its Update method, ie call poco.Update() from mono.Update(). Is that the same cost as calling methods declared inside your MonoBehaviour, or does it add some overhead? Thanks!

  • @TroL0iO1er
    @TroL0iO1er4 жыл бұрын

    Lmao I didn't know this is a design pattern but I have been using this pattern all along lol

  • @kuzmychmaksym3843
    @kuzmychmaksym3843 Жыл бұрын

    Also like to listen tavern music when working)

  • @Ratstail91
    @Ratstail914 жыл бұрын

    Cheesy acting - I love it. Actually, do you think you could address IDEs eventually? I hate all of the extra stuff that VSCode puts on the screen, like types and reference counts, etc. I love the simplicity of Sublime Text - maybe others will too?

  • @EricKesterson

    @EricKesterson

    4 жыл бұрын

    You can toggle a lot of that stuff off in VS Code. That said, I'd love a guide to moving to Rider for Unity, as I haven't made the jump yet.

  • @klarnorbert

    @klarnorbert

    3 жыл бұрын

    Search settings for Codelens, and turn it off.

  • @uweeby69
    @uweeby694 жыл бұрын

    Are you only able to run tests from IDE via Rider? Do you know if its possible in VS or VSCode?

  • @revraitah
    @revraitah4 жыл бұрын

    The font looks really clean, what is it called? Thanks in advance!

  • @happypixls
    @happypixls4 жыл бұрын

    Out of curiosity here, what are you thoughts about designing this a bit differently? I'm not talking about a substitute for the humble object pattern. I'm talking about the mashroom and haverstable relationship/concept? Couldn't you just refactor the verb/action bits into an interface, so whatever/whoever implement the IHarvestable interface can be harvested. besides, you could take all the data and probably couple common functionalities (such as applying the effect of the collectable to the collectee (if that is even a word? xD)) and tuck it away in a ScriptableObject leaving just the unity logic within Monobehaviour. What do you think?

  • @InfallibleCode

    @InfallibleCode

    4 жыл бұрын

    Absolutely! That would be one of many valid approaches to this problem :D

  • @captainnoyaux

    @captainnoyaux

    2 жыл бұрын

    Never used scriptable object what would it look like ?

  • @happypixls

    @happypixls

    2 жыл бұрын

    @@captainnoyaux Oh, you are in for a treat :D kzread.info/dash/bejne/aKqhtNmFibq0gtI.html

  • @redboss5429
    @redboss54294 жыл бұрын

    this format will always make me feel uncomfortable, good content tho lol

  • @pistoleta

    @pistoleta

    4 жыл бұрын

    I have the feeling Bharles is gonna tell Charles he’s not real.... 🤷‍♂️

  • @tylocook
    @tylocook4 жыл бұрын

    Is this the first mention of Bharles, or have I just missed it? 😐

  • @InfallibleCode

    @InfallibleCode

    4 жыл бұрын

    I think this is only the 2nd or 3rd time. It’s always subtle and hard to catch, though haha

  • @vordrax1014

    @vordrax1014

    4 жыл бұрын

    @@InfallibleCode Should have gone with "Gnarles" as a subtle but respectable shout-out to Gnarles Barkley.

  • @JonahDominguez
    @JonahDominguez3 жыл бұрын

    i get the feeling that charles was talking shit the moment that he hung up

  • @nicolasbrunet6430
    @nicolasbrunet64303 жыл бұрын

    0:23 what kind of monster clic like that.

  • @zandzpider
    @zandzpider4 жыл бұрын

    Wish the camera setup was a bit crisper. seems a bit grainy and out of focus? not sure if it's YT killing it or what. anyway excellent content

  • @Abken.
    @Abken.4 жыл бұрын

    Good video as always. I would write public bool IsHarvestable { get => _harvestable.IsHarvestable; } as a property instead of a public field. But otherwise really good content

  • @maritoxG

    @maritoxG

    3 жыл бұрын

    He write a property in minit 6:18 (public bool IsHarvestable => _harvestable.IsHaverstable) that is a property;.

  • @robertkadrgulov6615
    @robertkadrgulov66153 жыл бұрын

    Hi, dude, what keyboard do you use? what do you call a mointor

  • @malcolmholliday9710
    @malcolmholliday97104 жыл бұрын

    Do you have someone read the lines with you? It sounds really really smooth

  • @InfallibleCode

    @InfallibleCode

    4 жыл бұрын

    Thanks! I actually run them alone, which looks really weird when I play back the footage during editing lol

  • @nathanielsaxe3049
    @nathanielsaxe30492 жыл бұрын

    0:51 3:40 6:29 8:53 9:04 9:09 9:13

  • @kannpai

    @kannpai

    2 жыл бұрын

    Doing the lord's work

  • @nathanielsaxe3049

    @nathanielsaxe3049

    2 жыл бұрын

    @@kannpai heheh

  • @arkreo
    @arkreo4 жыл бұрын

    What code editor are you using? Nice practice indeed!

  • @darkbibni

    @darkbibni

    4 жыл бұрын

    That seems to be Resharper (a visual studio extension)

  • @InfallibleCode

    @InfallibleCode

    4 жыл бұрын

    It's called Rider. It has all the features of Resharper and much much more.

  • @arkreo

    @arkreo

    4 жыл бұрын

    @@InfallibleCode Thanks!

  • @yoimokacc
    @yoimokacc3 жыл бұрын

    Is this something you should do even outside of it's use for testing? It's merit isn't very clear to me outside of that.

  • @googleuser4720
    @googleuser47204 жыл бұрын

    2:04 Well... Ackshuallllyyyyyy!

  • @Nikxan
    @Nikxan4 жыл бұрын

    Charles, please tell Bharles that he is a lammer :)

  • @thefunnybuddy4138
    @thefunnybuddy41384 жыл бұрын

    Post a video about how to get a programming friend like that.

  • @SimonTysland
    @SimonTysland3 жыл бұрын

    Alright, I just have to speak my mind. I say it with love and hope you take it as constructive criticism. You are a good coder, a good teacher and have great content. But I just can't handle this video format. I'm getting frustrated trying to skip over the non informative parts (the unecessary acting parts in the beginning), and try to get to the information I came here for. I much rather like your tutorials where you are straight to the point: This is what I am going to teach you and how.

  • @beardordie5308
    @beardordie53084 жыл бұрын

    Xharles has telekinesis and is vegan on Tuesdays. Zharles plays saxophone and will usher in the end of all things. Wake up, each of your selves, open all your eyes! All of them!

  • @sodium7554
    @sodium75543 жыл бұрын

    Can someone recommend a good channel that doesn't waste 3/4 of the time on narration? Thansk.

  • @JuanPablodelaTorre
    @JuanPablodelaTorre3 жыл бұрын

    is it just me or does Charles feels a bit condescending to Barles?

  • @asdd2a
    @asdd2a3 жыл бұрын

    why he talk with him self

  • @keuriseutopoe
    @keuriseutopoe4 жыл бұрын

    Talking with yourself the whole video was so weird bro.

  • @psinjo
    @psinjo4 жыл бұрын

    It's not that the information was bad, but personally I found it very difficult to follow what was going on. It was like watching over someone's shoulder while also trying to listen in on their conversation. Personally I'm not really a fan of the set up acting to show off whatever you're trying to demonstrate. I found it both confusing and distracting, but some other people seem to like it. Different strokes for different folks, just wanted to throw out my two cents. I would have much more appreciated just saying 'here's my code, here's what it does, here's what's wrong with it" instead

  • @TheSpacecraftX
    @TheSpacecraftX4 жыл бұрын

    Is it just me that finds it weird to use var everywhere? Feels like it throws away some of the benefits of explicit static typing.

  • @greglyons288

    @greglyons288

    4 жыл бұрын

    It's lazy writing.

  • @beardordie5308

    @beardordie5308

    4 жыл бұрын

    @@greglyons288 it's fine so long as the type is apparent. It's not lazy. IMO

  • @axmoylotl
    @axmoylotl4 жыл бұрын

    conversation between two a.is pretending to be human

  • @47Mortuus
    @47Mortuus3 жыл бұрын

    Why are you so afraid of structs? Do you _LOVE_ garbage collection?