Тёмный

Shorter Cleaner Code with Extension Functions - C# and Unity 

One Wheel Studio
Подписаться 31 тыс.
Просмотров 5 тыс.
50% 1

Опубликовано:

 

14 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 21   
@geri4367
@geri4367 3 года назад
I've never seen this being explained so clearly, so concisely and with such good reasoning behind all the points made throughout the video. Good job and keep it up!
@mcgeufer
@mcgeufer Год назад
I make games with Unity for a long time, this thing, I missed so far. So this procrastination session was time well spent.
@1DrowsyBoi
@1DrowsyBoi 3 года назад
One super useful one that I use all the time is a "GetRandom()" method, made for ILists. This way, I can avoid the constant - and tedious- other way of: int roll = Random.Range(0, longListName.Count); var item = longListName[roll]; I also made overloads for this, that gives me a list of random elements, being able to set a stale queue (only returns an element once per X minumum other elements have been added), etc.
@OneWheelStudio
@OneWheelStudio 3 года назад
I love that idea! Getting random elements get verbose in a hurry!
@NowKnownMAWO
@NowKnownMAWO 2 года назад
public static T GetRandom(this List list) { return list[Random.Range(0, list.Count)]; }
@erz3030
@erz3030 3 года назад
Very cool stuff! I had no idea this was even possible, and so easily! Cheers
@xmetax
@xmetax 2 года назад
This is pretty nifty. Thanks 👍
@jugibur2117
@jugibur2117 3 года назад
Wow, this is really useful - thanks for posting!
@OneWheelStudio
@OneWheelStudio 3 года назад
Prefer written tutorials? Here's the blog post for the video: onewheelstudio.com/blog/2021/7/14/c-extension-methods Project File: github.com/onewheelstudio/Adventures-in-C-Sharp/tree/main/ExtensionMethods
@umapessoa6051
@umapessoa6051 3 года назад
Nice video, please keep doing more.
@andreybirchenko1767
@andreybirchenko1767 3 года назад
Wow! Thank you so much. You explained it very clearly!
@asembahra6187
@asembahra6187 3 года назад
Thanks for the nice video !
@syluxdev
@syluxdev 3 года назад
Life saver and Useful!!! 😄
@_Garm_
@_Garm_ 3 года назад
@2:35 i did not get, where you got vectorFloat from: vectorInt = vectorFLoat.TOvector3Int(); could you please elaborate a bit more :)
@OneWheelStudio
@OneWheelStudio 3 года назад
"vectorFloat" is just a name of a variable of the type Vector3 - just the usual type nothing special. I named it that to try and make a clear separation between the float and integer version of Vector3.
@_Garm_
@_Garm_ 3 года назад
@@OneWheelStudio Thank you, now i understand :D
@kvskchaitanya4733
@kvskchaitanya4733 3 года назад
Waiting for a video of writing proper managers without singletons.
@OneWheelStudio
@OneWheelStudio 3 года назад
Events and static functions! But mostly events! :) I have at least a dozen managers in my personal project and not a single use of the Singleton Pattern. It's not always a bad pattern, but I think it is mostly used to communicate between managers. A lot of that communication can be done with events that doesn't cause massive coupling of different classes. All that said, this could be a cool idea for video! Any problems in particular you've run into? Problems you are trying to solve?
@kvskchaitanya4733
@kvskchaitanya4733 3 года назад
@@OneWheelStudio I have used singletons to create managers but it has dependencies as project grow I just want to know if there is proper way of doing it. Thank you for the information.
@OneWheelStudio
@OneWheelStudio 3 года назад
Yeah. That does happen. If you aren’t familiar with it check out the observer pattern - ie events, actions and delegates
Далее
Generics in C# and Unity - Do More with Less Code
12:40
Unity Coroutines - What? Why? How?
11:03
Просмотров 46 тыс.
Why I Don't Like Singletons
29:05
Просмотров 82 тыс.
The New Extensions EVERYTHING Feature of C# 13!
10:32
How to ACTUALLY get into Gamedev
14:01
Просмотров 732 тыс.
Should I pass by const reference or by value?
10:45
Просмотров 106 тыс.
20 Advanced Coding Tips For Big Unity Projects
22:23
Просмотров 190 тыс.
15 Useful Shortcuts to Code Faster with Visual Studio
12:01
My 10 “Clean” Code Principles (Start These Now)
15:12
Nix explained from the ground up
23:39
Просмотров 43 тыс.