10 Things You NEED to Be Doing in Unity
A collection of vital tips and techniques I use in Unity every day. Some are Unity specific, while some are just good programming practices. Let me know if I taught you anything!
❤️ Become a Tarobro on Patreon: / tarodev
=========
🔔 SUBSCRIBE: bit.ly/3eqG1Z6
🗨️ DISCORD: / discord
✅ MORE TUTORIALS: / tarodev
0:00 Intro
0:08 Serializing components
1:18 Drawing scene gizmos
1:35 Initialization order
2:31 Stop using public fields
4:30 Mod to loop collections
5:04 PlayClipAtPoint
5:55 Limit extern calls with SetPositionAndRotation
6:53 Operator overloading
8:17 Composition
8:56 Don't use lazy naming conventions
Пікірлер: 578
Every programmer should keep this in mind while coding: "Code is read much more often than it is written"
@TheClanFollows
Жыл бұрын
And it is written much more often than it is understood 😂
@dominikzawlocki3117
Жыл бұрын
@@TheClanFollows I like this
@zardify_
9 ай бұрын
Pls someone tell this to my boss...
@prppnd3811
5 ай бұрын
Clean Code by Robert C. Martin?
@rickloyd8208
Ай бұрын
Once I followed the tips from the book you quote, the speed of writing increased significantly! It's kind of less stress on your brain =)
I've also a tip for beginner : don't over focus on optimisations, instead make your game. If your game is not optimised, you can do it later. But if your game is not working because you spent too much time implementing good practices and well designed patterns - over commenting your code, you gonna loose precious time and energy. When you are experienced and you know what are the pros and the cons of using a specific method you will automaticly try to use the best of it. Bu when you're a beginner, just make the game.
@hiakofficial8180
9 ай бұрын
Man you've saved me, I realized i was doing the same thing, i wanna go with the best practice so my didn't have to write the code again
@benjamindameworth5351
5 ай бұрын
The only optimization you should do along the way is optimizing the way your code is organized. If you don't organize your code it becomes unreadable for future you
@heyreefes
5 ай бұрын
My ass looking thru five hundred methods to make the character move so I can have the most optimised and best one
As a hobbyist dev im actually glad you made a video for the naming conventions. It wasn't until way later that i would read the subject from a book and wouldn't pay much attention to it. Also a not so beginner Tarodev tutorial that I understand! Kinda proud of myself!
@Tarodev
Жыл бұрын
You're turning pro ;)
@Shorkiedokey
Жыл бұрын
I'm a bit confused, because I name functions with PascalCase, should I name functions and public variables the same way? What would you say it's a good way to name them? Thanks.
@Tarodev
Жыл бұрын
@@Shorkiedokey function should always be PascalCase 😊
@Tarodev
Жыл бұрын
@@nikolicd91 I use standard C# conventions. The way unity does it is inferior and has a bunch of convention collisions. Unity should have enforced proper C# conventions from the beginning, but didn't. In addition, Unity uses a wide range of conventions, even in their samples and live events, so you really shouldn't use them as a benchmark for coding conventions.
@RealisiticEdgeMod
Жыл бұрын
I use syntax highlighting instead of these ugly underscores. Just make local vars a different color.
Your videos have the highest knowledge density. Never fails to amaze me in these short videos.
My man rolled out of bed, threw on a shirt with a hole in it and started spitting C#/Unity knowledge. Love it. Great video!
A quick note with the mod to loop collections section. Using mod like that does have 1 bug with it, and that's the clipIndex could wrap once it hits Int.MaxValue, causing it to not loop correctly, and also since the int is signed, it'll eventually crash once it hits the negative values. Instead I would write it as _clipIndex = (_clipIndex + 1) % _clips.Length, then index directly using _clipIndex.
@TheKr0ckeR
Жыл бұрын
That was question in my head actually. Since the game is very long for example, IDX value will get so much higher values. So in first example, we reset the value to 0 which even if its a long way, still proper way. I was trying to find a better way to reset idx.. But your example seems legit.
@generichuman_
Жыл бұрын
@@TheKr0ckeR If it's a 32 bit unsigned int, and it's incremented 60 times a second, it'll take about 2.26 years to overflow. That's a long time to run a game.
Dude you are SO INSPIRING! Happy to see you back! You should totally do a 'let's build a small game from start to finish' type course where you implement these good practices! Would instantly buy it.
@Tarodev
Жыл бұрын
Funny you say that... 😉
Great video! Love love love that you covered the naming conventions again and didn't back down! Soooo important for the exact reasons you mentioned. ❤️
Coding conventions are so important. Even as a solo dev. This last one is a great tip! Always remember: readability is king. It's SO important for the person who will read your code next. And you SHOULD care about that person - cause 9 out of 10 times, that person is you! 😁
So nice to see you getting back to releasing videos And on the last point - I think there is a special place in hell for people that say "I code for 35 years and do not use naming conventions" 🤣
@Tarodev
Жыл бұрын
No farm sim, just felt compelled to draw a cute cow for the video, which ended up taking longer than the video itself... I always seem to do that :D Thanks mate!
@anlozge1788
Жыл бұрын
@@Tarodev cute indeed.
@Tarodev
Жыл бұрын
@@anlozge1788 Me or the cow? ;)
@PitiITNet
Жыл бұрын
@@Tarodev BOTH!, So you have drawn it all yourself?! :o That's impressive!
@Tarodev
Жыл бұрын
@@PitiITNet Nope, background was from Adobe Stock + Gaussian. I did draw the cow, with heavy reference art though.
One minor issue with the modulo approach to index cycling is the index variable isn't really an index anymore, more like a counter, and related to that you could potentially run into overflow issues with really big numbers (not that it's really all that likely).
@YassineZaroui
Жыл бұрын
Isn't the Modulo also a bit slower?
@gregoryfenn1462
Жыл бұрын
Absolutely, to give a simplified example of the problem: suppose we have x a uint8_t (unsigned 8 bit int). Then define "i = (x++ % 5)". Starting from x=0 we have i = 0,1,2,3,4,0,1,2, ... but when x is 255 we have i = 0. Then when x increments it goes from 255 to 0. But that means i is 0 again, so the pattern breaks whenever x overflows. Of course in most games we use uint32_t or sint32_t, so this won't happen for a long time. But if the counter goes up several times a frame, it will still overflow after a few minutes or hours which can create a hard to detect bug later down the line. So for me I would always explicitly wrap an integer back to 0 manually rather than rely on modulo operators.
@houtamelocoding
Жыл бұрын
@@YassineZaroui Maybe? Branches are also slow so the proper way of knowing this would be benchmarking.
@saniel2748
Жыл бұрын
@@houtamelocoding Modulus can't be predicted, it's just a very slow operations. Possibly one of the slowest math operations you can have And Mono is also not smart enough to replace '% 2' with '& 1' That said, hundred of modules per frame, most certainly, won't change your FPS in any meaningful way
Dude I had no idea that Unity serializes properties, thanks
OMG! Using the modulus for iteration to avoid overflow is mindblowing. It was so obvious I don't know why I didn't think of it.
@Tarodev
Жыл бұрын
But now we have the problem of overflowing the int :P Only use it if you know it won't (99% of cases it won't).
Thank you for this one. I'm trying my best to get industry standard coding, and stuff this goes above and beyond. You are so far out of the hundreds of youtubers in this category that is unequivocally straight to the point and the most professional. Looking forward to diving into more of your videos.
Thank you, every second from your every video is pure gold diggin... thank you!!! And thank you for the naming convention, I've had my fair share of confusion, bugs, and misreads due to wrong use of naming convention... Thanks for serializing a property, the mod wraparound thing and operator overloading... so useful, and more importantly so nicely explained... thanks.
The mod to loop collection was sick Awesome 👍
@1Tasteless
Жыл бұрын
Agreed. Going to save me so much time in the future.
@pythonxz
Жыл бұрын
That one made me realize that I need to use modulo more. It's an elegant syntax.
@Meow_YT
Жыл бұрын
Not really. That variable is now unbounded and will wrap around eventually, with possible issues if the compiler has checks on integer overflows not known about?
@ishan9050
Жыл бұрын
@@Meow_YT interesting point. Definately will have a look. Thanks for the mention
You are my favorite gamedev tutorial KZreadr! All your videos are very helpful for me!
@Tarodev
2 ай бұрын
And you're my fave commenter of today!
Along the lines of naming conventions, one thing I think can be really useful is writing out booleans as lines above the check, for example: var jumpWasPressed = Input.KeyDown("Space") if(jumpWasPressed) { //do jump stuff} The code itself is a comment, and it prevents comments/code from getting out of sync. This is of course a broader topic about variable names in general, but that's one I do that I think would benefit a lot of code since it explains the "why" of the boolean/etc in many cases. Also, if the variable is within a function scope and you're not returning it or etc, it's not allocating (on heap) or etc, so there is no real performance difference.
@WatchingTokyo
Жыл бұрын
This is great advice. This kind of technique allows to clarify what it is we meant to be testing.
Thanks a lot for those hints. I am a fan of not making it harder than it is. Plus: Programming is the art of making yourself not lose track of the things you are doing. The very first thing I came up with was to separate variable scopes through naming conventions. This makes life a lot easier.
Great stuff! Thta tip with position and rotation really f'ed me up! Been using unity for years and never knew that function existed!
Composition sounds a lot like the structure in ECS. Where an entity is given components. Rather than inheriting from another entity. I built a similar composition system for my hierarchical state machine. Where I have one state that only holds states. So that I can add a state for camera actions, a state that handles controls etc. Separating actions and features which also hold their own stats to do their own thing. While the core values "transform, camera, rigidbody" called context. Are all on the player for all states to access.
Great video, all helpful tips for beginners and old timers alike. Thanks again and keep doing your thing Tarodev!
@Tarodev
Жыл бұрын
You know what? I will
Loved the part on naming conventions. In addition is good to remember always to give useful names for the variables, that also makes all the difference.
I kept typing out comments to add to what you were saying, only for you to go on and say exactly what I was going to say! I'm a software developer by trade, and work in C# on a daily basis, building an enterprise product. Whenever I sit down to learn something about Unity, I end up spending a bunch of time griping about how I don't get the latest c# features, and critiquing (in my head) the actual C# code that's used in many of the tutorials out there (including first party ones!). It's really refreshing to see someone using C# to its fullest, great video!
Finally, a new video! And a good one for sure. As a senior dev, you reminded me of the operator overloading and the neat tricks you can do with them. You could do a video on extension methods (like advanced level). I saw some seriously good sh*t with them. Duck typing in C# is a very cool feature.
@Tarodev
Жыл бұрын
I actually have a video on extension methods... Ancient though. Don't remember how advanced I made it
@soverain
Жыл бұрын
@@Tarodev Yeah, I remember, but that was not so advanced, still very useful.
Naming Conventions have always helped me quickly solve coding issues that crop up during projects, I didn't realize so many people didn't use them until I started entering GameJams.
I probably knew the majority of these already, but using the [field:SerializeField] attribute to specify that the backing field should be serialised on a property is actually ingenious shorthand. Thank you so much!
@jmarsh411
Жыл бұрын
Same!
I like having the convention that every 'prefab' I reference for instantiation is ALWAYS a gameObject then I never worry about having to change it's type and losing all my references. But that's just a personal choice. Great video!
@user-rl2ox1bu4c
Жыл бұрын
Agree with this one. Good video though.
Quick note: The "public Type Variable => ReturnValue;" Syntax creates a readonly property, so its not the same as having "public Type Variable {get;private set;}". The difference is, that the readonly property cannot be changed even by the instance itself, it has no setter.
@Tarodev
Жыл бұрын
You're completely right, thanks for the correction!
@bread8176
Жыл бұрын
The value can still be changed by directly modifying the field it accesses, so in *practice* it is the same. (unless you mark the backing field as readonly as well)
@Erkle64
Жыл бұрын
@@bread8176 Same in what you can do. Different in how you can do it.
The. Return. of. the. King! Good to see you, Sir. Thank you for the tips, the helpful details, and the easy to understand ways to impliment them. As always, I'm happy to see your video, and I'm looking forward to both your upcoming ones, and your larger projects. Good luck and good health.
@Tarodev
Жыл бұрын
Long time no see!
10:20 When it comes to naming conventions, people don't really mention a convention for naming function parameters. In my experience, I have personally found it more convenient to tell the difference between an injected value vs a value held or created by this object than anything else. People just lump local variables and function parameters together, but to me I just feel like a variable potentially injected from another class should be distinguished from a local variable, especially when using ref/out. I feel like C# standard naming conventions aren't really made for game development, because it puts more emphasis on identifying public vs private variables when I just don't use public variables for game development. The 3 categories for me are class values, function values and injected values.
100% agree on the Naming Convention point. I personally use the following; public Type variableName (Camel Case) private Type _variableName (Underscore Camel Case) public/private void MethodName(Type value) { var variableName (Camel Case) } This allows instant identification of public variables, private variables, and methods, not just for scope but functionality as well. All function-scoped variables are camelCase as they are easily identifiable as local within the scope of their parent method. While the author, whom I have deep respect for, recommends using PascalCase for public variables & properties, I however, find using PascalCase only for MethodNames makes it impossible to confuse methods with similarly named properties. Just my 2¢. 😁
Naming convention is indeed a good idea. I do try to go a step further by adding some details in the var name itself. so_something for scriptable, go_something for gameobject, etc.
@Tarodev
Жыл бұрын
This is very interesting. I can certainly see this being beneficial
@pythonxz
Жыл бұрын
I add prefixes for my filenames, but that's a good idea too.
@PPSzB
Жыл бұрын
It's called a hungarian notation and many people advise against using it, especially when using modern IDE. One of the downsides is you have to remember to change variable name when you change its type (like in the GameObject and Carrot example)
Man you are my favorate youtube unity knowledge master! I had no idea they added serialization of get set properties! Keep up the good work!
@Tarodev
Жыл бұрын
Only on properties with a backing field, just be aware 😄
I'm with you regarding naming conventions.
@Tarodev
Жыл бұрын
And I'm with you
Thanks for the video, always a good thing to see we can still learn something. For the code convention, I just notice I don't use the underscore private field just because jet brain color the local as white and the private / public as green (dependends on theme ofc)
Another great no nonsense vid :) Took away so many tips from this. Thx
Excellent Tips! I didn't think about DrawGizmos for spawn points. I been doing the inspector gizmos and complain about the size, but now for sure I will start with drawgizmos instead
you always teach me a lot and make me a better programmer. thank you Taro
I feel so good now that I know I have been doing these for quite some time now, and better to know the things I totally missed, thanks for the heads up 😘😘
The naming convention thing is pretty smart. I do underscore for local and lowercase for all others, but I'll start testing uppercase for public going forward. Thanks for the tips!
The naming conventions I use were taught to me in my CS courses. Cap class publics, mCap for private class variables, then lower for local variables. I sometimes use a fourth convention specifically for counters which use usually an _ or C_
@Tarodev
Жыл бұрын
As long as there is something in place to save you that extra parsing step, you're doing it right.
@MuhammadHosny0
Жыл бұрын
use C99 naming conventions.
great tips, I didn't know many of these even though I've been working with unity for 2-3 years. For naming conventions, I use "m_varName" for private variables, uppercase initials for public variables, underscore for parameters and lowercase for locally scoped vars. It greatly improved the readability of my code for my own sake.
Thank you so much for sharing. It's really informative and helpful 🙂
I really appreciated the section about naming conventions! I've been following a lot of tutorials that use the same conventions you mentioned, but I didn't understand why people always used _ in some variables, or capitalized others. I'm definitely going to follow this more now.
@Tarodev
Ай бұрын
You'll be happy you did :)
Thank you so much! your videos are always a treasure trove of incredibly useful information🙂 And serialized get-set property - its awesome!😎
@Tarodev
Ай бұрын
That one's my bread and butter
These are always super useful, thank you! keep making them plz. Cheers.
Love it. Thank you very much man. (twenty years of dev and 3 years in Unity here)
@Tarodev
Жыл бұрын
You're very welcome Servaus 🙏
Great video! all perfect advice, and reminded me about the serialized properties :)
Thanks a lot for these useful tips! Do you have a video about how to save persistant data (option preferences typically) or tips about that subject?
Great videos! Would be great to see some videos from you explaining UniRX, Zenject or MVC
Love your work. One thing I find hard teaching students is the naming conventions - partly because Unity seems to just randomly capitalise stuff, so my rule is to stick to my naming convention (essentially the C# Microsoft recommendations) and just accept that Unity is different!
@Tarodev
Жыл бұрын
This is my way too Maxy boy...
Wow... 3:44 Serialized 'Properties' is huge... I didn't notice that change and I really appreciate you mentioning it. It always bothered me to write a full propery to conform to Unity and C# coding conventions..! Thank You!
so much KNOWLEDGE! Awesome video, Taro -- I specifically liked the phrasing at the end with coding conventions: "would have gotten along a little bit better" 😆
@Tarodev
Жыл бұрын
Makes it a bit tricker for them to bite back at me 😁 Glad you enjoyed it, Nicky!
I've been using unity for quite a long time and did not know most of the tips in this video. Thank you sir🥰
@Tarodev
Жыл бұрын
Welcome :)
I was wondering where that naming convention video went, glad to have it back because I coudn't agree more and have been using it myself ever since!
@Tarodev
Жыл бұрын
Fills me with joy to know I converted you
@BLANKdev
Жыл бұрын
@@Tarodev it really is that much better sorry everyone 😬
The single method call for setting both Position and Rotation is actually very recent (in at least 2021 LTS). They added it just a couple of patches back - 2021.3.11f1 I think.
@Tarodev
Жыл бұрын
Makes sense why I've only just discovered it, I guess 😁
@Deadener
Жыл бұрын
For real? I could have sworn I've seen it since like 2018. edit: Yep, I've found threads on it dating back to 2017. It was added in Unity 5.6.
@Xankill3r
Жыл бұрын
@@Deadener you're right. I mixed it with the get method for position and rotation which was added in 2021 LTS. Plus the set for both added to TransformAccess.
+1 for the naming conventions. Thank you.
Good work man . We waiting alot of time ,just dont forget us and upload this great video 😄😄
That last tip felt like a direct roast to me😂 and it hurts even more to acknowledge that you're completely right. There's a some great tips in here! Thanks😁
08:57 I was confused about this. Now i'm done! Thanks so much for this and the others.
Nice to see you back buddy... Great...Mind-blowing
@Tarodev
Жыл бұрын
Thank you Syed 🙏
I'm glad you said that people really need to use inheritance when it fits the situation. Always use the tool that seems the most appropriate. As for naming variables (or really anything in code), do not abbreviate unless it is very obvious what it stands for. I've also seen far too many people leaning on comments to explain a function, when naming the function something more descriptive would do just as well.
@Tarodev
Жыл бұрын
People can get carried away, you know?
Great content as usual. Extra points for the sporty look today.
@Tarodev
Жыл бұрын
Ready for action at all times
I've been using unity for a while and still learned something, so thanks!
This channel is always pure GOLD!
It's funny because the naming conventions, I've always flipped local and private from what you do, but there is another benefit to doing it your way. If you are in your IDE and you type "_" then your private variables will populate the IntelliSense popup, and not your public, which can be handy for setting variables that no other scripts will have access to, since it will still look pretty on the outside, but remain easy to read and write on the inside. I also did not know about overloading the operators, that is indeed a VERY cool trick. It's a tier above extension methods, which are already S tier. Thank you for making this video, I always look forward to them!
As for naming conventions, I agree that they are quite important! Good on you for pushing them! But I don't find it all that useful, in Unity, to know whether something is public, private, or local via a naming convention. Partly because Visual Studio automatically color codes the different scopes. But mostly because the scope for most component based scripts is so small anyway. Occasionally you get a big 5k line PlayerScript or something... but most other scripts are what... 30-100 lines? So why bother with scope naming. What DO I find useful for naming conventions then? GameObjects, Prefabs, Component refs, types and spaces. GameObjects => "go" prefix. goBullet. goPlayer. goEnemy. No more confusion about what an object is or isn't. Prefabs(onDisk) => "prefab" or "pf" prefix. No more guessing if a GameObject reference is actually a GameObject or a disk reference. Components => "cp" prefix. cpBullet. cpPlayer. cpEnemy. cpAnimator. etc. Just by the variable name, I know which component it is, and which functions I can call on it. Transforms => "xf" prefix. xfBullet. xfPlayer, etc. Types, ie Vector3 vs Vector2 => I put a v3 or v2 in front, respectively. v2PlayerPos for 2D game. v3Direction, etc. And yes, for floats, ints, strings, as well. Spaces, ie WorldSpace vs ViewPort vs ScreenSpace etc. v3PlayerPosWS is a world space position. v2BulletDirXZ is a direction but in XZ axis only (ie, top-down shooter). v2MousePosSS for mouse cursor position in screen space. This will save your sanity. Keep the tips coming! Love it!
@Tarodev
Жыл бұрын
Good write up. I like the idea of prefixing their types. I do it for some things, but not necessarily a prefix, for example: _scriptableUnit _projectilePrefab
@Nullzero98
Жыл бұрын
@@Tarodev this is the way, my friend!
@Etherealscorpions
Жыл бұрын
I definitely see where you're coming from with naming by type, but if you're asking for help on forums, or helping people on forums or similar, then the scope naming conventions - or at least, being able to quickly explain your variables' scope to a third party - makes it much easier on everyone involved.
@badscotsman
Жыл бұрын
What you're referring to is called Hungarian notation.
@johnhershberg5915
Жыл бұрын
A lot of people disagree, but I stopped using naming conventions altogether. I use PascalCase for everything. What I noticed was that it was wasting brain resources thinking stuff like "This serialized field has the health set from the editor, and it's at 100 by default, but on this enemy it's 120, and I'm taking damage which comes from the function parameter which right now is 70, and multiplying it by this locally scoped variable..." etc etc. Instead when I'm parsing logic, all I should care about is the logic. Pretty much never do I care about where it comes from. So what I want to instead be thinking is "Health is 120, and I'm taking 70 damage, and multiplying that by 2". Historically the reason for underscores is so if you need your IDE to show you the top-level stuff (serialized fields in our case) you could just type _ and it'll bring up IntelliSense for those. But in my personal opinion that's a distraction these days. If you're back to reading code after a long time it's probably because something is wrong. You should be focusing on the logic of what's happening in the function rather than where things are coming from. Just my humble 2 cents. It sounds weird, but try it and see for yourself.
Dude, I can't believe I didn't know most of these! Thanks for sharing!
Lot of good stuff here. Thank you!
@zeiksz
Жыл бұрын
I tried this property -> field thing, because that was new to me, but worked only if it was basic like public int Teszt { get; set; }, but once I did something like [field:SerializeField] public int Teszt { get => teszt; set => teszt = value; } int teszt; it no longer showed in the inspector. The goal was to call event in the setter, etc. Any idea, what I did wrong? Or is this a bug/feature?
I rarely write any comments, but you are just too good. I wanted to thank you for all of your videos, which helped me a lot in game-development. Keep quality of your work on high level, man, thats why we enjoy it! I recommend this channel for every developer i know. Cheers from UA game-dev Community!
@Tarodev
Жыл бұрын
Damn. Thanks dizmo 🙏
Great video with some useful tips. Thanks ☺
As always, awesome video man. Cheers
That serialize property tip. Been waiting for that for a while.
Great tips. Especially the field: serializedField tip, and the lambda short-hand. Will be using both of those for sure! As for Prefabs, they are awful to deal with when it comes to the Inspector. Easily one of the hardest parts of Unity for beginners to understand. The fact that Prefabs are called Prefabs, but can be serialized as Components and GameObject fields in the Inspector is so confusing. I really think they should just have a PrefabFile type or something, and any serialized field declared as PrefabFile should only allow references to prefabs saved on disk. Yes, you lose flexibility, but that's the point... no level or game designers shooting themselves in the foot by dragging the wrong thing into a generic GameObject field.
Your hot tips are always welcome mister tarodev
There was so many “ohhhh this is so cool” moments
@Tarodev
Жыл бұрын
Mission accomplished
Your video is always great! Thank you so much :)
Something which I don't see listed in the summary is enabling advanced play options in the editor settings. This allows one to choose whether to reload stuff or not on play, which most of the time isn't needed if you're just working on level-design for instance. It'll most likely save most devs precious seconds when entering playmode. Remember to disable it when working on advanced features though!
@Tarodev
Жыл бұрын
I actually have an entire video dedicated to this 😘
Great tips, thank you!
Overriding the + operator is pure genius!
yesss knew all of them :D great video again :)
This video is pretty good. I learn a lot thanks to you
Yes, please follow naming conventions ^^, it's immensely helpful and expediates the process of reading code.
Thanks for the tips - esp for the naming convention tip.
My general recommendation is to have a naming convention and stick with it. It doesn't matter which convention you use, but if you're in a group use whatever the group's convention is.
@Tarodev
Жыл бұрын
I totally agree. In the real world you shouldn't barge into an established group and try change their conventions. Certainly fight for a good rule set if you're there at conception though.
@doommustard8818
Жыл бұрын
I like to name functions/methods with Capitals private begin with _ Events begin with On *Listeners begin with When scoped variables can get away with not being descriptive because I don't have to look at code I'm not currently working on to know what they're doing so I don't have a convention for them other than comments on their definition *If the listener is solely used as a listener and too complex for lambda notation
Thank you for this useful video :)
Well I certainly didn't know we can serialized properties now. Thanks a lot! :D
I clicked because the thumbnail is so good. I stayed because this is very useful lol
The property serialize field thing was new to me thx!
As a new dev I constantly need to go back to my codes to change something cause I learned a better way to do it, and I found myself lost in my own code several times. naming conventions not only saves time but also its way less stressing if, as I, you're coding for 3-4 hours after your 8hr job. definetelly will implement these
Great video man 👍
Those are some solid things to keep in mind :)! I really enjoy these "quick tip" videos, there's always stuff for me to learn in them. I see the Gameobject being instaniated so often... And personally, I write "public" variables until I get the first version or prototype to work and then redo them :D [field:SerializeField] was new to me, I'm absolutely using this from now on! (Plus: super cute cow!)
@Tarodev
Жыл бұрын
That's an important point to keep in mind... Do whatever is quickest to get a prototype out. No point writing perfect code with scalable subsystems on a game which will never see the light of day.
Thanks for the video. A small observation: at 4:47 even though you will be able to index correctly, at the end of the function _clipIndex might be an out of bounds index. Maybe a "++_clipIndex" instead of "_clipIndex++" would be better in this situation.
That's the same naming convention I've been using for about a decade. I don't like when private fields and local scopes have the same naming style, I get lost on what I'm reading. Regarding the transform extern bit, if you're calling transform a lot, shouldn't you just cache it as a private field? That modulus tip is beautiful! Im gonna try that one! Thanks for the tips!
nice tips and trixx, again!
Good stuff, thanks.
Thanks for the really informative video! I'm learning a lot through your channel. Embarrassingly, I have been using inconsistent naming conventions for a large amount of scripts within my project, due to lack of dev experience (and some laziness) It has always been a constant concern during development Would you still recommend starting to stick to naming conventions for future scripts?
At first I wanted to complain about the title being too clickbaity, I didn't expect to learn much new stuff but wtf get set fields can be serialized?! Your videos never disappoint. This is amazing.
hey man, i always love to see your videos. I'm a total beginner, i really don't understand yet 80% of what you're talking about, but being exposed to it and seeing how you solve somethings really helps, and is fun. Is there any source material or tutorials you recommend for beginners? apart from the unity learning page of course. Thanks
@Tarodev
Жыл бұрын
Honestly, when I started learning to program, I just built things. When I became stuck, I searched directly for that information. After a few years of constant grinding, I was in a pretty good place. Alternatively, you can find a good course, but it personally wasn't for me. It most likely would be a faster approach, though.
@Fefs-yi1gf
Жыл бұрын
@@Tarodev thanks for the input. Yeah, I think that's the best way, just building something and looking for answers when stuck, have done it for other things, will try it with this subject too. 🙏