MENU

Fun & Interesting

Why you should NOT make everything PUBLIC!

Code Monkey 122,901 lฦฐแปฃt xem 3 years ago
Video Not Working? Fix It Now

๐ŸŒ FREE C# Beginner Complete Course! https://www.youtube.com/watch?v=pReR6Z9rK-o
๐Ÿ”ด Watch my Complete FREE Game Dev Course! ๐ŸŒ https://www.youtube.com/watch?v=AmGSEH7QcDg
๐ŸŒ HumbleBundle MEGAPACK https://cmonkey.co/humblebundle
โœ… Unity Summer Sale (ends soon) https://assetstore.unity.com/?aid=1101l96nj&pubref=notpublic
๐ŸŒ Get my Complete Courses! โœ… https://unitycodemonkey.com/courses
๐Ÿ‘ Learn to make awesome games step-by-step from start to finish.
๐ŸŽฎ Get my Steam Games https://unitycodemonkey.com/gamebundle

๐Ÿ’ฌ 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! โœ… https://unitycodemonkey.com/courses
๐Ÿ‘ Learn to make awesome games step-by-step from start to finish.

๐ŸŒ Get Code Monkey on Steam!
๐Ÿ‘ Interactive Tutorials, Complete Games and More!
โœ… https://store.steampowered.com/app/1294220/

If you have any questions post them in the comments and I'll do my best to answer them.

๐Ÿ”” Subscribe for more Unity Tutorials https://www.youtube.com/channel/UCFK6NCbuCIVzA6Yj1G_ZqCg?sub_confirmation=1

See you next time!

๐Ÿ“ Support on Patreon https://www.patreon.com/unitycodemonkey
๐ŸŽฎ Grab the Game Bundle at https://unitycodemonkey.com/gameBundle.php
๐Ÿ“ Get the Code Monkey Utilities at https://unitycodemonkey.com/utils.php

#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 - https://www.youtube.com/user/Unity3D
Brackeys - https://www.youtube.com/user/Brackeys
Dani - https://www.youtube.com/channel/UCIabPXjvT5BVTxRDPCBBOOQ
Jabrils - https://www.youtube.com/channel/UCQALLeQPoZdZC4JNUboVEUg
BlackthornProd - https://www.youtube.com/channel/UC9Z1XWw1kmnvOOFsj6Bzy2g
Sykoo - https://www.youtube.com/user/SykooTV
Jason Weimann - https://www.youtube.com/channel/UCX_b3NNQN5bzExm-22-NVVg
Jonas Tyroller - https://www.youtube.com/channel/UC_p_9arduPuxM8DHTGIuSOg
--------------------------------------------------------------------

- Website: https://unitycodemonkey.com/
- Twitter: https://twitter.com/UnityCodeMonkey
- Steam: https://store.steampowered.com/developer/EndlessLoopStudios

Comment