Learn about what delegates are, when to use them, compare their functionality with a UnityEvent, and when you should use a UnityEvent over a delegate! In this video we'll be covering all of that and implementing our first delegate so we can raise an event when our AutoDestroyText is destroyed!
If you've been using Unity for a while, or are just getting started with Unity and decided it's time for you to start learning how to write code - this is the video series you need to start your programming journey!
👨💻 As always! The full project code is available GitHub: https://github.com/llamacademy/unity-...
Full Series Playlist Here: • Want to Start Writing Code in Unity? ...
⚫ Part 1 - Writing your first script - • Want to Start Writing Code in Unity? ...
⚫ Part 2 - Loops and Arrays - • Loops and Arrays | Unity C# Basics Pa...
⚫ Part 3 - Unity Component Lifecycle - • MonoBehaviour Lifecycle Basics - Awak...
⚫ Part 4 - Static vs Instances - • Static vs Instances | Unity C# Basics...
⚫ Part 5 - Delegates - • Delegates? Basically, UnityEvents. Bu...
⚫ Part 6 - Inheritance & Interfaces - • Inheritance and Interfaces for Beginn...
⚫ Part 7 - Compositional Relationships - • Compositional Relationships - You've ...
📝📝📝YOUR HOMEWORK!📝📝📝
Update your singleton MonoBehaviour to raise events when it spawns an object and when that object is destroyed! For the simplest implementation you can just do a Debug.Log but think about the signature of the event so you can apply it to your game!
Add a comment below with a video showing your code and the end result.
📚 Here are the resources I mentioned and/or brought up during the video 📚
⚫ Delegates: https://docs.microsoft.com/en-us/dotn...
⚫ Using Delegates: https://docs.microsoft.com/en-us/dotn...
⚫ Unity Events: https://docs.unity3d.com/ScriptRefere...
⚫ Singleton: https://en.wikipedia.org/wiki/Singlet...
💸 Ongoing sales 💸
⚫ See all active asset sales on the Asset Store: https://assetstore.unity.com/?on_sale...
⚫ Save 25% off your first Asset Store Order: https://prf.hn/click/camref:1101l9QvC...
⚫ Save up to 50% on NEW Assets: https://assetstore.unity.com/?new_sal...
❤ Believe in LlamAcademy's mission and have received value from the videos? Become a Patreon Supporter or YouTube Member:
⚫ Patreon: / llamacademy
⚫ YouTube Member: / @llamacademy or click the Join button on any video
----
Most tutorials come from knowledge gained making https://survival.llama.software Llama Survival - a top-down zombie survival shooter for Android and iOS.
I also have some Unity Assets (affiliate link): https://assetstore.unity.com/publishe...
Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.
#unitytutorial #tutorialtuesday #gamedev #tutorial #unity #llamacademy #gamedevelopment #learntocode
Chapters:
00:00 What is a Delegate?
02:15 When do you use Delegates?
02:52 Real Life Example
04:19 Defining your first delegate
05:27 Raising an event with a delegate
06:30 Adding handlers to a delegate
07:52 Demo 1
08:36 Quickly Implementing an Object Pool
09:40 Removing Handlers from the Delegate
10:54 The Importance of Removing Handlers on Recycled Objects
11:20 Final Thoughts about Delegates
12:22 When to use Delegates vs UnityEvents
13:40 Homework!