5 Tips and Tricks for Unity C# in 6 Minutes

preview_player
Показать описание
Here are five Unity tips and tricks that I've discovered over the years while developing my own games. I hope they'll make your life easier and your code cleaner. It's not meant to be a thorough tutorial, just a bit of exposure, so there are links further on to research more yourself.

==========================================

==========================================

If this video gets enough attention, I have some ideas for a part 2, so let me know in the comments if you want to see that! I'm always looking for feedback so let me know if there's anything I should improve or keep doing (eg. on the memes to more relatable).

==========================================
Links for More Info

==========================================
Timestamps:
0:00 - 0:10 : Intro
0:10 - 0:45 : 1. XML Comments
0:45 - 2:10 : 2. Interfaces
2:10 - 2:30 : 3a. Named Arguments
2:30 - 3:01 : 3b. Optional Arguments
3:01 - 4:06: 4. Custom Unity Template Scripts
4:06 - 5:16 : 5. Various Refactor Tools
5:17 - 6:07 : Channel Info

#unity #gamedev
Рекомендации по теме
Комментарии
Автор

Awesome tips, I try to use Interfaces as much as possible to decopled code responsabilities, It's a pity that Unity doesn't support dependency injection or SerializeFields with interfaces, but I'm using a Gameobject for this.

BBdaCosta
Автор

Great video! Really helpful.
I just had to re-watch some parts to hear what you where taking cuz the screen was showing a separated information that made me lose track.

matheusfrancisco
Автор

Nice video. I'm currently doing something similar a card game with a board but with a different game logic than you. I don't use pixel art but I'm not a very good artist... I'm learning a bit the theory but I really need to do a lot of practice now. I like your puppet/mockup/silhouette for the enemy with all the different shapes that you can use to animate more easily before the final render ;)

TreizeSC
Автор

A neat video, I have a little feedback on done architecture things you mention.

Xml comments! Oh no! Only if you're exporting an API too a third party, otherwise they're cost without benefits. Good naming and SRP should be enough.

Another way to think of interfaces are as behaviours rather than descriptors. Eg ITakeDamage or ICanFly. Interfaces are less useful in component architectures (Unity) because the components are loosely coupled be default.

You should avoid inheriting from the base class, as favouring composition over inheritance will stop your base class from breaking Liskov substitution. Composition in Unity is performed by lots of components on an object (rather than dependency injection, which isn't core to Unity's design).

OO class at uni will give you basics but they stop short of SOLID/DRY/YAGNI/Clean Code/XP, all of which will stop your larger code base from becoming spaghetti.

I hope that's useful!

RobLang
Автор

I usually turn to foreach whenever possible, but the main issue with foreach is that you're not allowed to edit elements you're cycling through while you're at it.

demyanrudenko
Автор

what colour theme are you using? I have always struggled with good colour themes on VS

BlacKHellCaT
Автор

Interfaces are good and named arguments too. Optional arguments not so nice, they make your method overloaded, you can use it, but with conscious.
Custom unity templates - maybe are good, but with 6 years of unity experience - I don't use them even once.
Various refactor tools - are good - but visual studio are bad - use better IDE like JetBrains Rider or Consulo.

WeslomPo
Автор

Comment will not improve your code, even worse. They can bloat your code. When you write comment, you bear responsability that you will have to support code AND comments. When you stop support comments they will lead you wrong way. Support something is serious burden - with comments you will twice it. Write code that not need comments - much better.

WeslomPo