10 Things You NEED to Be Doing in Unity

10 Things You NEED to Be Doing in Unity

Tarodev

1 год назад

126,234 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@MAXmillium
@MAXmillium - 17.11.2023 20:36

I just subscribed to you and you pull out the naming convention card right away.
I never use naming conventions and do just fine. All my vars are built using only the letters [I, i, l, 1] and i just remember what the vars mean.

Ответить
@netpeggle4458
@netpeggle4458 - 06.09.2023 21:54

the cow is realy cute

Ответить
@fruitsodahmm6044
@fruitsodahmm6044 - 24.08.2023 08:57

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?

Ответить
@BS990507
@BS990507 - 20.08.2023 20:25

currently kind of binging your tutorials especially because you are sticking to the MS c# naming convention. Other tutorials or code snippets often dont use them and it can get hard to follow because of this. Thanks for advocating this!

Ответить
@KentBrakewell
@KentBrakewell - 15.08.2023 09:18

Good points made in this video. I do the same for prefixing variables by scope, except that in place of the underscore, I use 'm' to confer (m)ember-level scope. I know I've arrived too late to save the world, but at least for my personal code base I prefer a semantic mConvention over the more widely-accepted _convention. I totally agree with awarding the most readable format (TitleCase) to the public members. There are additional benefits to prefixing that weren't covered in this video, although minor by comparison. 🤏

Ответить
@EManLGI
@EManLGI - 15.08.2023 01:35

This video hurts me 😬

Ответить
@AJ213Probably
@AJ213Probably - 14.08.2023 01:31

Oh no... I didn't know about Play Audio Clip At Point... I just have been summoning gameobjects with audio sources

Ответить
@theperson101ful
@theperson101ful - 05.08.2023 10:49

@Tarodev Could you please do a video on common optimizations, my GC.Alloc in the profiler is 90 - 100MB and I have no clue on how to get it smaller. Our app is used with a lot of scrollviews and loops, also not a game but a lot of interfaces. Love your videos, thanks!

Ответить
@papafhill9126
@papafhill9126 - 05.08.2023 07:34

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!

Ответить
@zachbellew7292
@zachbellew7292 - 03.08.2023 08:29

Great point about the singleton access in awake but really you shouldn't be doing your singletons like that. There are much safer patterns to use such as calling constructor on access and using a lock.

Ответить
@sevazakharenko8176
@sevazakharenko8176 - 31.07.2023 10:43

It's hard to find "official" good naming conventions because the .NET C# standards say to use 'PublicVariable' for publics, and '_privateVariable' for private as you mentioned, but also use 'ConstantNumber' for constants which I don't agree with. I prefer my constants screaming at me like CONSTANT_NUMBER. But I guess that's frowned upon.

I think just use whatever naming convention you and your team get along with as long as you don't use hungarian notation! Thank you for the tips, cheers!

Also as a side note, the Half-Life 2 code uses SCREAMING constants also, though it is written in C++ not C#..

Ответить
@LajosUti
@LajosUti - 30.07.2023 11:24

How come the IDE is not showing the difference between class member variables and locally scoped variables? That should do the trick. Say no to underscore variables people :D (Just joking though, use them if you won't get code reviews from me).

Ответить
@NotJustUnity
@NotJustUnity - 26.07.2023 13:33

Thanks for your video ! Agree to what you say about Initialization Order, messed up this lead to the Race Condition problem.

Ответить
@lizkimber
@lizkimber - 25.07.2023 11:14

so in your example of carrot.. first thing i noticed and has put me off your video is that you declare carrot at the top.. but you then at the line in question do "var carrot =" therefore, you are redeclaring it and rendering your point mute.

Ответить
@4sent4
@4sent4 - 24.07.2023 17:04

On the topic of using `mod`, it is usually slower than `if`, so saving couple lines of code can end up costing performance a bit. Usually this is not noticeable, but if you do it too much, it can add up

Ответить
@mateuszpatua3016
@mateuszpatua3016 - 23.07.2023 22:11

I can't find your vid on naming conventions. Am I stupid or what?

Ответить
@phee3D
@phee3D - 22.07.2023 18:28

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.

Ответить
@nicreven
@nicreven - 20.07.2023 02:59

y'know taro while I do agree with your getters and setters tip it's soooooooooooooooooo much easier to not do that :D
Great vid though!

Ответить
@ravivandersalm4586
@ravivandersalm4586 - 19.07.2023 19:51

Access modifiers only make sense to me if someone's life depends on the variable. Otherwise it just seems like a waste of time

Ответить
@zORg_alex
@zORg_alex - 19.07.2023 00:53

Unity messed people up having lots public properties in camel case in their classes. This made me to do the same just so it would look consistent with existing code. But I refuse to use m_ naming.

Ответить
@nexxogen
@nexxogen - 16.07.2023 08:45

Two more pro tips:

1. Don't use Java brackets in C#. And especially don't combine them with C# brackets like in this video. C# has standards and the brackets are opened in the next row. No exceptions here.

2. Don't ever use public class variables, like shown in the last tip. Use a private variable (with an _) and expose it through a property. That way, you don't have to worry about public field naming conventions - you will never use them.

Ответить
@pchoudhary
@pchoudhary - 15.07.2023 10:58

Naming conventions, as an experienced c# programmer, I just started with this. And then Rider said, no this is nOt right for unity 😢

Ответить
@chizuru1999
@chizuru1999 - 03.07.2023 18:32

I just saw that modulo trick today on the svelte tutorial 😂👌🔥

Ответить
@harshitjoshi3082
@harshitjoshi3082 - 21.06.2023 19:04

Great video man 👍

Ответить
@arjunmehta2853
@arjunmehta2853 - 17.06.2023 16:10

Apart from naming conventions, I think what I'll seriously recommend is using regions to divide different parts of your code. If you have a script that has a lot of complicated code, using regions helps so you only concentrate on the part that needs to be worked on. Also keeping public and private variables separately is a great idea, if you mix up the private and public variables in the same area then you start having to squint, but if they're separated(u can even use regions if they are a lot) you know where to look.

Ответить
@NodrapLego
@NodrapLego - 07.06.2023 11:49

Nice video. Not a fan of naming conventions because if you don't know what the variable you are using is for then a naming convention isn't going to save you. But to play devils advocate I think there is a 4th format that should be included. My biggest bugbear is a variable that is really a function. You can write very inefficient code if you don't know that accessing a variable in fact invokes a load of code hidden in a get, for example. For me I always use the Capital letter start for anything that is a function so I at least know to check how complex it is and, for me, this is more likely to have a beneficial result in my code over knowing if something is private or not.

Ответить
@xepherys
@xepherys - 04.06.2023 17:58

Naming conventions are so useful - I'll even go one further. While I swap camelCase and underscore (camelCase for class privates, _underscore for local methods variables), I also do reverseUnderscore for loop variables. While it isn't super useful for iterators `for (int i_ = 0; i_ < someValues; i_++)`, I still use it so everything is the same.. Where it's nice is for object in objects things, like `foreach (Color color_ in colors)`. That tells me that `colors` is a class collection, and `color_` is my local iterated value. I've even toyed with the idea of underscore for variables local to the scope inside of a loop, which can be helpful sometimes if it's super long. Something like that `foreach (Color color_ in colors)`, setting `Color tmpColor = {someValue}` inside the loop helps in a large loop to quickly see that it's a hyper-locally scoped variable.

So, `PascalCase` is always public (usually a property - even if it's a public {get;set;} I tend to prefer fields to always be private), if it's `camelCase` then it's a class private, if it's `_underscoreCamelCase` it's local to the method, if it's `reverseUnderscoreCamelCase_` it's an iterated value, and if it's `_doubleUnderscoreCamelCase_` it's a hyper-local variable in a loop.

Ответить
@baoinh2968
@baoinh2968 - 02.06.2023 19:27

thank for share 🥰

Ответить
@Monstermoerder1
@Monstermoerder1 - 24.05.2023 13:04

I agree with the naming convention for big projects, I just don't like using Pascalcase for variables. Pascalcase is for Classes / Structs / Types in my book. But then again, C# also wants you to use Pascalcase for Functions / Methods, so who am I to say who's right. Just find some different ways of writing your differently scoped variables.

You could go a step further and use yet another prefix for parameters vs variables, if you'd like to keep those separate as well.

Ответить
@littleowlgaming-unity-tutorial
@littleowlgaming-unity-tutorial - 03.04.2023 19:57

that hair! makes you look that crazy uncle that goes on big jogs wears high socks and gives nothing at Christmas, and always working on some get rich schemes.

Ответить
@fanerv3304
@fanerv3304 - 02.04.2023 19:09

I've just realised how much I do not know.
Great video!

Ответить
@OmniCroissant
@OmniCroissant - 01.04.2023 17:36

Hi. New programmer here. Where aren't you supposed to make a field public ? And how can you make scripts communicate between each others if not ?

Ответить
@ziccodx
@ziccodx - 26.03.2023 22:55

Yes, please follow naming conventions ^^, it's immensely helpful and expediates the process of reading code.

Ответить
@haslo_
@haslo_ - 15.03.2023 01:24

My naming conventions are: Always this. for private, regular camel case for method variables, public variables don't exist.

Ответить
@davidpoussif6944
@davidpoussif6944 - 12.03.2023 20:03

Great videos! Would be great to see some videos from you explaining UniRX, Zenject or MVC

Ответить
@fokeyjoe
@fokeyjoe - 07.03.2023 16:06

Suggestion for future tips, dealing with scaling and unit measures - there must be some tricks to digging about the for the mesh bounds and setting localScale?
If you're a contractor you'll know all about different naming conventions!! Though it's interesting when linters get involved (in JS world they're prolific) because they are sometimes so opinionated that they discourage people from adopting new or better strategies for their code, though they hopefully teach you new ones too!

Ответить
@maxfun6797
@maxfun6797 - 06.03.2023 06:51

Salutations Tarodev, can you show me how to run my ml-agent training on a dedicated server with gpu? docker build might be the easiest. Or i can just unzip the project and cd into the virtual environment (this is windows, so I guess it wont work). Anyway you are a servers guy, can you be of help to me here?

Ответить