Dependencies in Unity

  Рет қаралды 32,117

Infallible Code

Infallible Code

Күн бұрын

Пікірлер: 84
@asfand6904
@asfand6904 4 жыл бұрын
I love this mentor/mentee format, the issues aren't contrived but rather come up organically. Also it actually feels like a conversation I would have with a colleague.
@In-N-Out333
@In-N-Out333 4 жыл бұрын
You can also trigger an event when an item is collected and have the ui class subscribe to it. This is better than constantly checking for it in update.
@9paradox
@9paradox 4 жыл бұрын
Can't wait to see the in depth story of constructor in monobehaviour.
@YairVich
@YairVich 4 жыл бұрын
Too
@InfallibleCode
@InfallibleCode 4 жыл бұрын
“Once upon a time there was a C# class that wasn’t like all the other C# classes...” Lol long story short, Unity does some stuff behind the scenes that would break if you override your MonoBehaviour’s constructor. It could make for an interesting video, though
@UnityTest-p6n
@UnityTest-p6n 9 ай бұрын
It's a pure programmer fantasy: to have a more experienced friend who magically calls you the moment you run into a problem in your code XD
@NotLard
@NotLard 4 жыл бұрын
Dude you're like my programming dad now. Thank you so much for making these
@legendaryitem2815
@legendaryitem2815 4 жыл бұрын
The best practice, especially in context of UI updates is to loose couple the classes and get rid of those dependencies through events. For example, every time you pick up a carrot your inventory class could raise an event CarrotCollected or CarrotCountChanged and expose the value of Carrots through the event. The carrot label class can then catch that event and update itself accordingly - provided it has registered a delegate to work as the event handler. I find this to be much better for testing because you can test elements of your application independently without having to have a ton of classes that you need to put in the test scene because are all dependent on one another.
@DarkMatterVisible
@DarkMatterVisible 4 жыл бұрын
It's always refreshing to see someone use internal resolutions effectively. Too often programmers (including people from Unity!) advise new programmers to avoid "get" and "find" like they were the plague, but after you've been through a few projects you realize when used properly they significantly reduce the complexity of the project and increase readability considerably. Of course these should never be used in Update when they will be running continuously, but in OnEnable, Start, Awake, all of the times when it will take place outside of gameplay, it's one of the best tools creators have. I went from trying to wield scriptable objects into my inventories and item systems and all of the needless complexity involved in that, to months later realizing I could simply use single scripts or classes along with a couple get or finds, save them with their prefabs, and reduce the complexity of my projects by many orders of magnitude. Sometimes I think people at Unity just don't understand game development, at all.
@ivanyablonskyi812
@ivanyablonskyi812 2 жыл бұрын
problems start when people learn programming first, and Unity - second. And people like me, who learned Unity, and then programming. We just think different)
@RootLocusSquare
@RootLocusSquare 3 жыл бұрын
This is amazing. I now can understand why these tutorials write code these way. And the slang that developers use.
@CodingWithUnity
@CodingWithUnity 4 жыл бұрын
Really good video! Another way to think about how dependencies are done is the same as how a car is made. Cars are made in a factory and then sent out, each car doesn't contain its own factory. So why inside the logic of your code would you be building the parts of your class that it needs to function, that's the same as having a factory inside your car. It's better to build your class and then send it out to the world, not build it while it's begin used.
@InfallibleCode
@InfallibleCode 4 жыл бұрын
Great analogy!
@StefanLopuszanski
@StefanLopuszanski 4 жыл бұрын
Yeah, that is one of the first things I teach my students. Don't put expensive things in Update unless you have some type of bool to turn it off after it is done! Caching is generally better, but sometimes you need it to run with the object already existing. Could split it off but there are multiple options on handling it. And you should put all those calls in Awake over Start to ensure the Dependencies are connected before Start does the logic on it.
@nikaklnikak6152
@nikaklnikak6152 3 жыл бұрын
You're doing good talking with yourself. I wish I could do that too so I wouldn't need any friends anymore.
@bhilder
@bhilder 4 жыл бұрын
Your videos are legit the best unity tuts
@johnes2337
@johnes2337 4 жыл бұрын
It would be cool to see you go through character development and character arcs throughout the tutorial series to keep viewers enticed to see what happens in the next tutorial video.
@clifflin7149
@clifflin7149 2 жыл бұрын
I really like how you explain everything, Thank you and keep up the nice video!
@nGAGE0nline
@nGAGE0nline 4 жыл бұрын
You're so lucky to have yourself as a good friend. I am my worst nightmare. :D
@artemisDev
@artemisDev 4 жыл бұрын
You should treat Charles a cup of coffee now and then
@InfallibleCode
@InfallibleCode 4 жыл бұрын
I agree! All he does is give and give while Barles just takes and takes. It’s an unhealthy relationship!
@seanadkisson582
@seanadkisson582 4 жыл бұрын
lol i like the video format, where u are having a conversation.
@ACatWithACrown
@ACatWithACrown 4 жыл бұрын
One way I like to manage dependencies, especially with simple Ui things such as that, is through Actions, or events. Pretty neat stuff (:
@shintarouemiya
@shintarouemiya 4 жыл бұрын
Is there any extension for VIsual Studio that displays current "drag-and-drop" dependencies from Unity like on 6:08?
@Juan-lj4pi
@Juan-lj4pi 4 жыл бұрын
Just leaving a comment in case someone answers
@gix7273
@gix7273 4 жыл бұрын
I love the cheezy "me-and-myself"-thing ^^
@CowboyCoder21
@CowboyCoder21 4 жыл бұрын
Awesome content!! I love these, keep it coming!
@Messi0come0back
@Messi0come0back 4 жыл бұрын
big fan of Barles!
@maxarefev5686
@maxarefev5686 2 жыл бұрын
I can't see a solution here for a situation, where we have state management in the game, and in many components, we should subscribe for the state changing to handle it. Should I pass state instance through SerializableField in 10 places?
@redpyre
@redpyre 4 жыл бұрын
No one's ever seen Barles and Charles in the same room at the same time
@FuzzyDPozzy
@FuzzyDPozzy 4 жыл бұрын
I have a question: 1.Where do you use Dependency injection? 2.Why do you we use it? 3.You said something zen Inject which i've heard before? what does it do? it is allow you to use constructors? 4.Anything to be careful with ? like where not to use dependency injection?
@RichyAsecas
@RichyAsecas 4 жыл бұрын
What's that awesome font your Rider has?
@LazzyDawg17
@LazzyDawg17 4 жыл бұрын
I primarily deal with Invalid Dependencies revolving around “packages: com.unity.2d.tilemap@1.0.0” and “packages: com.unity.2d.2dsprite@1.0.0” every time I try to open up my project, I can still continue, but I’ve been dealing with this issue for months....
@blasder007
@blasder007 4 жыл бұрын
this is top tier content, thanks!
@peacefuldeityspath
@peacefuldeityspath 2 жыл бұрын
Hey! what coding font do you use? ;o it looks amazing mines are unreadable and i wear glasses. this looks like it can help me
@scriptsengineer
@scriptsengineer 4 жыл бұрын
Great video series! Make more tutorials, of ECS for example! Thanks!
@InfallibleCode
@InfallibleCode 4 жыл бұрын
Soon... maybe!
@PeterMilko
@PeterMilko 4 жыл бұрын
another great video
@adek445
@adek445 4 жыл бұрын
Great vid! Really helpful! :)
@Soundy777
@Soundy777 4 жыл бұрын
The whole time I’m watching this I’m just thinking:: “Is Skype still a thing ??!”
@InfallibleCode
@InfallibleCode 4 жыл бұрын
I rarely use Skype IRL but I felt like it had the most recognizable ringtone xD
@Soundy777
@Soundy777 4 жыл бұрын
Infallible Code That ringtone does hit those hairs in the back of your neck with nostalgia. Classy play mon ami.
@albatross479
@albatross479 4 жыл бұрын
what are u using var carrots not int carrots?
@huyopo
@huyopo 4 жыл бұрын
Dependencies will cause a lot of issues in your project if you don't pay attention. But theres a really simple fix for most issues: use assemblies. You can't have circular references, so your game core can't reference the ui and so on. That forces you to write better code.
@QFSW1024
@QFSW1024 4 жыл бұрын
Definitely a good way to make structural dependencies more manageable but it won't solve data dependencies like this But yeah I agree with the advice.
@InfallibleCode
@InfallibleCode 4 жыл бұрын
Yes, the rule of thumb is to make sure that your dependencies only flow in one direction.
@tedlanz5038
@tedlanz5038 4 жыл бұрын
Watching the conversation between the guy and himself triggered my Multiple Personality Disorder! Luckily I was able to FindObjectOfType() to solve the problem. Unfortunately, it crashed my brain up and I had to reboot! Ahhh...the problem with using Windows Vista to power my brain!!!!
@benardallotey
@benardallotey 4 жыл бұрын
I need to know your Rider color scheme please!!
@LanPodder
@LanPodder 4 жыл бұрын
how is he getting those warnings?
@SanderDecleer
@SanderDecleer 4 жыл бұрын
He is using an IDE called Rider.
@chilpox3671
@chilpox3671 4 жыл бұрын
You are my favourite schizophrenic youtuber
@alvin4100
@alvin4100 3 жыл бұрын
Same I just found there are terms to these things lol
@andreamengoli4656
@andreamengoli4656 4 жыл бұрын
Meen amazing so funny and usefull!
@rafaelcorrea7959
@rafaelcorrea7959 4 жыл бұрын
There should be a video about events, calling update on something that is not changing, is not optimal.
@PxlDev
@PxlDev 4 жыл бұрын
Subbed!
@beardordie5308
@beardordie5308 4 жыл бұрын
I sympathize, Charles, I don't have any friends, either. Problem is, my name already starts with a B, so I don't have a B-version of me to Skype with. 😢
@AlekseyLoykuts
@AlekseyLoykuts 4 жыл бұрын
Okay, can i add Charles to my Skype contacts, so everytime i stuck, he'll call me? At my rate he'd probably be online the whole day
@eaglenebula2172
@eaglenebula2172 4 жыл бұрын
Man I hate dependencies, it's one of the things that complicate the code and reduce its flexibility the most in my experience in complex projects like 3D action RPGs.
@mehmedcavas3069
@mehmedcavas3069 4 жыл бұрын
Just use singletons in your whole project :O (just kidding)
@cristiano4826
@cristiano4826 4 жыл бұрын
Does your twin have a youtube channel?
@monkeyrobotsinc.9875
@monkeyrobotsinc.9875 4 жыл бұрын
haha he likes the way your sheep game looks.
@thatoneguy9153
@thatoneguy9153 4 жыл бұрын
I cringed when he typed the FindObjectOfType in the beginning. As a C# programmer of 10+ years, it made me want to vomit.
@StefanLopuszanski
@StefanLopuszanski 4 жыл бұрын
One comment about the video... this is a fundamental thing with passing information around and maintaining connections in your code. But you use a ton of advance terms without explaining them like constructors, get/set methods, serialization, attributes, and others. Also, you do things without explaining some of it, like using a SerializedField as opposed to just making it Public. It is okay, but I'd suggest doing a whole video on dependency management from the perspective of someone who is very new... like someone who has maybe done Roll-a-Ball. Would be a lot more useful for new people learning about this stuff. I'd assume people who already know how to use attributes and serialization and so on already know about dependencies, right?
@greglyons288
@greglyons288 4 жыл бұрын
Every video would require all those terms to be explained and re-explained. The point of this video is dependencies, and if you want to learn about those other topics, you can search them. If those terms don't make sense, then dependencies isn't a priority to learn about.
@StefanLopuszanski
@StefanLopuszanski 4 жыл бұрын
@@greglyons288 : See, that's where I disagree. Dependencies are a priority at some of the earliest levels of game development. Maybe if there was a video explaining most of those terms already then you could link to it, but I wouldn't say you'd have to explain it EVERY time... only in times that with fundamental concepts being covered. Can you name a game without any dependencies?
@sagiziv927
@sagiziv927 4 жыл бұрын
If you are a beginner, then you don't start with an advanced topic like dependencies. All of the thing you wrote above, are basic programming stuff that aren't supposed to be explained in an advanced video. If there was a term you didn't understand, you can search for it really easily. My honest advice (from personal experience) is yo focus on C# programming first (basic console application) and only after you mastered that, move to unity and build more complex projects.
@Juan-lj4pi
@Juan-lj4pi 4 жыл бұрын
@@sagiziv927 I started with unity and I loved it. Idk if I'm alone on this one but, understanding the basics of OOP came easier to me in an environment full of items, inventories, levels, ammo, hp and enemies than in "regular programming", were everything feel so abstract
@greglyons288
@greglyons288 4 жыл бұрын
@@StefanLopuszanski Beginners who do Roll a Ball probably don't even know the difference between a float and an int, and you want to also throw them more new vocabulary about dependencies? This is why there are courses that have progression. 10 minute KZbin Videos can't pull off what you're asking, and if you think it can, then make it.
@amisner2k
@amisner2k 4 жыл бұрын
Infallible Skype Call
@avitys5105
@avitys5105 4 жыл бұрын
it's a cool, informative hint video, but a little hard to understand because of bad English.
@michaeltyers7336
@michaeltyers7336 Жыл бұрын
This is so unrealistic. I mean who uses Skype?
@fawdept
@fawdept Жыл бұрын
ehat is he speaking bro
@valerii-barabanov-vvb
@valerii-barabanov-vvb 2 жыл бұрын
Don't give him a name, otherwise we can't associate ourselves with him :)
@2420-y2o
@2420-y2o 4 жыл бұрын
Get to the point.
Unit Tests in Unity
11:42
Infallible Code
Рет қаралды 119 М.
How Thinking in Systems Can Improve Your Code
10:16
Infallible Code
Рет қаралды 32 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Everything You Need to Know About Singletons in Unity
8:38
Infallible Code
Рет қаралды 89 М.
4 Tips for Refactoring Your Code for Readability
14:58
Infallible Code
Рет қаралды 31 М.
Humble Objects in Unity
9:46
Infallible Code
Рет қаралды 31 М.
Here's How You Should Be Thinking About Data
10:56
Infallible Code
Рет қаралды 36 М.
A BETTER way to setup new unity projects!
15:44
Jason Storey
Рет қаралды 57 М.
Unity3D Managers vs Controllers
12:06
Jason Weimann (GameDev)
Рет қаралды 58 М.
Unity3D SOLID Principles - Dependency Inversion Principle
15:45
Jason Weimann (GameDev)
Рет қаралды 62 М.
HACKING UNITY GAMES (FOR NOOBS)
16:11
cazz
Рет қаралды 102 М.