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
📦 Follow along by downloading the example project code at www.patreon.com/posts/38990018
Alternate title: Schitzophrenic refactoring unity code.
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
3 жыл бұрын
The Akinator of real life
@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.
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!
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..
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.
Very well put together as usual Charles and Bharles! This might be something to flesh out on the livestreams as well.
Just wanna say your videos are the best I've found on KZread, it's all as clean as it gets :)
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.
Cant wait for the introduction of Dharles. His shades are so cool.
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!
As surreal and deadpan this is, the conversational style was actually really easy to follow. Nice work bruv.
The important take away is there's a Tavern music playlist on spotify lol
@InfallibleCode
4 жыл бұрын
And it’s amazing lol
@gilbertobitt3757
4 жыл бұрын
I thought I was the only one that start listening it too
@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.
just learned new things Poco , humble objects and humble object pattern thanks Charles
This is high quality content (even the acting!). Great stuff, I'm learning a lot. You definitely deserve more subs!
Dude, I love this type of video!!! Keep it up⚡🔥
Great video as always, regardless of the topic I learn something from your videos.
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!
this design pattern is brilliant!!!
i love this whole idea of friend advicing you...just brilliant :)
Really nice! Great video!
Wow, man. You're awesome. Nice tutorial
Infectiously optimistic
@daslolo
3 жыл бұрын
until Charles starts making soap in the basement
Aweromse video! Thanks!!!
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!!
Gonna try out the Tavern music channel now
@InfallibleCode
4 жыл бұрын
It’s great! I love coding with it on.
You're really awesome dude.
Awesome!!
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
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?
3:39 The exact same thing I said! 😂
Great content again.. Humble object is my most favorite pattern .. Btw, what font are you using in Rider? It looks great!
@InfallibleCode
4 жыл бұрын
Thanks! It's called Victor Mono - rubjo.github.io/victor-mono/
great video! are you using visual studio?
Casually being a bro and a mentor to yourself.
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!
Lmao I didn't know this is a design pattern but I have been using this pattern all along lol
Also like to listen tavern music when working)
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
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
3 жыл бұрын
Search settings for Codelens, and turn it off.
Are you only able to run tests from IDE via Rider? Do you know if its possible in VS or VSCode?
The font looks really clean, what is it called? Thanks in advance!
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
4 жыл бұрын
Absolutely! That would be one of many valid approaches to this problem :D
@captainnoyaux
2 жыл бұрын
Never used scriptable object what would it look like ?
@happypixls
2 жыл бұрын
@@captainnoyaux Oh, you are in for a treat :D kzread.info/dash/bejne/aKqhtNmFibq0gtI.html
this format will always make me feel uncomfortable, good content tho lol
@pistoleta
4 жыл бұрын
I have the feeling Bharles is gonna tell Charles he’s not real.... 🤷♂️
Is this the first mention of Bharles, or have I just missed it? 😐
@InfallibleCode
4 жыл бұрын
I think this is only the 2nd or 3rd time. It’s always subtle and hard to catch, though haha
@vordrax1014
4 жыл бұрын
@@InfallibleCode Should have gone with "Gnarles" as a subtle but respectable shout-out to Gnarles Barkley.
i get the feeling that charles was talking shit the moment that he hung up
0:23 what kind of monster clic like that.
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
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
3 жыл бұрын
He write a property in minit 6:18 (public bool IsHarvestable => _harvestable.IsHaverstable) that is a property;.
Hi, dude, what keyboard do you use? what do you call a mointor
Do you have someone read the lines with you? It sounds really really smooth
@InfallibleCode
4 жыл бұрын
Thanks! I actually run them alone, which looks really weird when I play back the footage during editing lol
0:51 3:40 6:29 8:53 9:04 9:09 9:13
@kannpai
2 жыл бұрын
Doing the lord's work
@nathanielsaxe3049
2 жыл бұрын
@@kannpai heheh
What code editor are you using? Nice practice indeed!
@darkbibni
4 жыл бұрын
That seems to be Resharper (a visual studio extension)
@InfallibleCode
4 жыл бұрын
It's called Rider. It has all the features of Resharper and much much more.
@arkreo
4 жыл бұрын
@@InfallibleCode Thanks!
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.
2:04 Well... Ackshuallllyyyyyy!
Charles, please tell Bharles that he is a lammer :)
Post a video about how to get a programming friend like that.
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.
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!
Can someone recommend a good channel that doesn't waste 3/4 of the time on narration? Thansk.
is it just me or does Charles feels a bit condescending to Barles?
why he talk with him self
Talking with yourself the whole video was so weird bro.
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
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
4 жыл бұрын
It's lazy writing.
@beardordie5308
4 жыл бұрын
@@greglyons288 it's fine so long as the type is apparent. It's not lazy. IMO
conversation between two a.is pretending to be human
Why are you so afraid of structs? Do you _LOVE_ garbage collection?