Why you should NOT make everything PUBLIC!

  Рет қаралды 123,024

Code Monkey

Code Monkey

Күн бұрын

🌍 FREE C# Beginner Complete Course! • Learn C# Beginner FREE...
🔴 Watch my Complete FREE Game Dev Course! 🌍 • Learn Unity Beginner/I...
🌍 HumbleBundle MEGAPACK cmonkey.co/hum...
✅ Unity Summer Sale (ends soon) assetstore.uni...
🌍 Get my Complete Courses! ✅ unitycodemonke...
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Games unitycodemonke...
💬 As you're starting out you might learn to set things as public in order to expose them in the Editor.
In this video I tell you why you should NOT do that!
The reason is to write good clean code that minimizes code complexity. The less accessible your variables are the better.
If you have an error with a variable that is set to public, you don't know where the error comes from, it might be in that class or any other class in your entire code base since every class can modify that field.
However when you set it to private you make sure that any issues that occur have to be happening from within that class, that really helps on keeping a smaller mental model of what your code is doing.
And if you want to expose a variable in the editor, simply use the attribute [SerializeField]
That way you keep your code nice and clean but still keep it editable in the Editor.
🌍 Get my Complete Courses! ✅ unitycodemonke...
👍 Learn to make awesome games step-by-step from start to finish.
🌍 Get Code Monkey on Steam!
👍 Interactive Tutorials, Complete Games and More!
✅ store.steampow...
If you have any questions post them in the comments and I'll do my best to answer them.
🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
See you next time!
📍 Support on Patreon / unitycodemonkey
🎮 Grab the Game Bundle at unitycodemonke...
📝 Get the Code Monkey Utilities at unitycodemonke...
#csharp #unity #programming #unitytutorial #gamedev
--------------------------------------------------------------------
Hello and Welcome!
I'm your Code Monkey and here you will learn everything about Game Development in Unity using C#.
I've been developing games for several years with 8 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
I do Unity Tutorials on just about every topic, Unity Tutorials for Beginners and Unity Tutorials for Advanced users.
You can see my games at www.endlessloopstudios.com
--------------------------------------------------------------------
Other great Unity channels:
Unity - / unity3d
Brackeys - / brackeys
Dani - / @danidev
Jabrils - / @jabrils
BlackthornProd - / @blackthornprod
Sykoo - / sykootv
Jason Weimann - / @unity3dcollege
Jonas Tyroller - / @jonastyroller
--------------------------------------------------------------------
Website: unitycodemonke...
Twitter: / unitycodemonkey
Steam: store.steampow...

Пікірлер
How to Fix NullReferenceException in C#! (4 Step Process)
16:10
Code Monkey
Рет қаралды 86 М.
What are Events? (C# Basics)
15:05
Code Monkey
Рет қаралды 412 М.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
every step to actually make your dream game (then sell it)
24:27
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 820 М.
Unity Code Optimization - Do you know them all?
15:49
Tarodev
Рет қаралды 205 М.
4 Unity Destruction Libraries Compared - Which is best for you?
18:45
What are Interfaces? (C# Basics)
13:54
Code Monkey
Рет қаралды 217 М.
How Games Have Worked for 30 Years to Do Less Work
23:40
SimonDev
Рет қаралды 1,4 МЛН
Why you should switch to Unity's New Input System (and how easy it is)
9:51
Jason Weimann (GameDev)
Рет қаралды 34 М.
TOP 10 C# things you MIGHT not know (I didn't!)
12:18
Code Monkey
Рет қаралды 21 М.