How and Why to use Delegates in your C# Unity Game

  Рет қаралды 8,516

Dapper Dino

Dapper Dino

Күн бұрын

Пікірлер: 20
@Tikodev
@Tikodev 6 жыл бұрын
I like this “How and Why” series/idea that you’re doing. Straightforward and reasonable
@jamiebates5522
@jamiebates5522 6 жыл бұрын
Delegates are great but I feel that maybe I don't always recognise some of the situations where I should use them. I guess it's something you learn through experience :P My most common use of delegates is probably in the form of lambda expressions! One useful tip I learned recently, is how to use them to return something from a coroutine. Normally you can't return something from a coroutine since the return type has to be IEnumerator, but if you use this declaration instead: public IEnumerator OpenMenu(Action selectItem); with selectItem(choice); somewhere in the coroutine and then call the coroutine from somewhere else with: int selection; yield return itemList.OpenMenu(result => selection = result); It will return that int called 'choice' and store it in 'selection'
@龙雨-i6o
@龙雨-i6o 4 жыл бұрын
Best explanation I've seen so far, despite the frequent hesitations during recording.
@pigeonade
@pigeonade 6 жыл бұрын
Thanks for the tutorial! New sub here for sure. My constructive crits are: I think you should be clearer about what the purpose is at the start (a diagram perhaps?) and talk about your next video vote and patrons at the end. It would not be a huge jump in effort to be more prepared and concise. People searching for this one thing would appreciate it so much more.
@machine0man
@machine0man 4 жыл бұрын
Finally I understood Delegates . This is same as Event System Design Pattern.
@martycarr1477
@martycarr1477 6 жыл бұрын
@Dapper Dino - Coding Tutorials I'm getting into using these now. My question would be: you still need to access the script where the delegates located, obviously you can't use "find". What's the best way to get a reference to that delegate on another script? I feel like searching for the game ones l object and getting component is defeating the purpose of being efficient by using delegates in the first place.
@BlacKHellCaT78
@BlacKHellCaT78 3 жыл бұрын
I would put my delegates in a manager class for them and make it a static singleton, that way you can access it from whever you need you in order to subscribe to the delegate. You also most probably dont want the script that has your delegated to be constantly getting destroyed and initialised so you would want it to be a singleton
@batfasturd
@batfasturd 6 жыл бұрын
The only thing I would add is that Delegates can still be a weak point and in most cases I would advocate for using the event system instead as you can accidentally reset your delegate list with a single typo of using = instead of += when subscribing. Event systems tend to have a little more protection built in. Keep up the great work on the tutorials!
@paulrobinson5490
@paulrobinson5490 6 жыл бұрын
Nice tutorial. I've decided to make my game an open world game for PC (instead of multi level android game) do I need to put my save screen in the game scene or will it work from the main menu scene? New to all of this so sorry if sounds like a dumb question. Was thinking of putting the save button in the pause menu. Will be upping my subscription soon, the other one never even replies :(
@DapperDinoCodingTutorials
@DapperDinoCodingTutorials 6 жыл бұрын
Thanks for all the support it means a lot
@paulrobinson5490
@paulrobinson5490 6 жыл бұрын
That's brilliant and so helpful, thanks :) . Pleasure supporting someone who replies . you're a star
@Rai2M
@Rai2M 6 жыл бұрын
@@DapperDinoCodingTutorials They dont recommend to use DDOL anymore, afaik, they're like 'use a main scene and load subscenes' instead
@martycarr1477
@martycarr1477 6 жыл бұрын
@@DapperDinoCodingTutorials I'm getting into using these now. My question would be: you still need to access the script where the delegates located, obviously you can't use "find". What's the best way to get a reference to that delegate on another script? I feel like searching for the game ones l object and getting component is defeating the purpose of being efficient by using delegates in the first place.
@alicewithalex
@alicewithalex 6 жыл бұрын
Roguelike it's very cool, but it cant be good without Great dungeon generator. If you declare it in 3d - it will be cool, I wrote rogue game sometome ago in easy algorithm, but it was very bad experience) cause of bad knowing unity and c#. Maybe do Analogue to pixel dungeon in 3d with low poly model? U can do a blender mini series with it) and of course will be cool to write good generator with future updates ( for exanple: write it on default cubes, but when will be more time rewrite it for custom mesh) Good luck) It will be cool if you agree with it)
@Rai2M
@Rai2M 6 жыл бұрын
Generating dungeon main geometry is a (relatively) simple task, the main headache is when you're about to add all the stuff inside of it, especially if you want to connect multiply dungeons and make some sense of this mess :) Btw, the simple flood fill algorithm helps a LOT when it comes to setting up things properly :)
@Tomyk9991
@Tomyk9991 6 жыл бұрын
i could imagine a kind of minecraft from skretch. The interesting part is, that you have to worry about meshcombing and building chunks. i'd like to see your implementation.
@ptitjo9475
@ptitjo9475 4 жыл бұрын
5:10
@nikbates23
@nikbates23 4 жыл бұрын
Bro don't start talking about you patreon in the start of the video..
@phineasfacingforward3460
@phineasfacingforward3460 4 жыл бұрын
How else would people know about it?
@nikbates23
@nikbates23 4 жыл бұрын
@@phineasfacingforward3460 At the end of the video when they have shown that they actually can provide good content. It's like your waiter asking for a tip as you sit down at the restaurant
How and Why to use The Event System in your C# Unity Game
22:15
Dapper Dino
Рет қаралды 23 М.
OCCUPIED #shortssprintbrasil
0:37
Natan por Aí
Рет қаралды 131 МЛН
Вопрос Ребром - Джиган
43:52
Gazgolder
Рет қаралды 3,8 МЛН
Counter-Strike 2 - Новый кс. Cтарый я
13:10
Marmok
Рет қаралды 2,8 МЛН
C# Delegates & Lambdas Explained
32:43
Raw Coding
Рет қаралды 39 М.
How and Why to use the Generic Type T in your C# Unity Game
20:05
Delegation In C# - Delegates And Events And How To Use Them In Unity
31:57
Awesome Tuts - Anyone Can Learn To Make Games
Рет қаралды 10 М.
Events & Delegates in Unity
13:20
Game Dev Beginner
Рет қаралды 65 М.
How and Why to use ECS (Entity Component System)
18:06
Dapper Dino
Рет қаралды 8 М.
What are Events? (C# Basics)
15:05
Code Monkey
Рет қаралды 407 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 779 М.
The Power of Scriptable Objects as Middle-Men
17:41
samyam
Рет қаралды 132 М.
OCCUPIED #shortssprintbrasil
0:37
Natan por Aí
Рет қаралды 131 МЛН