Delegates in C# for Unity Coding Beginners | Unity C# Basics Part 5




Published: 07 Jun 2022

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!


Full Series Playlist Here: https://www.youtube.com/watch?v=SXaa61JWLDw&list=PLllNmP7eq6TTjwoyfRYAAFOH1sMHVgI1r


⚫ Part 1 - Writing your first script - https://youtu.be/SXaa61JWLDw

⚫ Part 2 - Loops and Arrays - https://youtu.be/MB6B9nHSrps

⚫ Part 3 - Unity Component Lifecycle - https://youtu.be/TD3yoFg3GVI

⚫ Part 4 - Static vs Instances - https://youtu.be/JRRlAzBh-6U

⚫ Part 5 - Delegates - https://youtu.be/1N6k7Hj_JKc

⚫ Part 6 - Inheritance & Interfaces - https://youtu.be/siRvSZzrhRU

⚫ Part 7 - Compositional Relationships - https://youtu.be/khIweJfnyW4


📝📝📝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.


🔶 ALL THINGS LlamAcademy now available at: https://llamacademy.dev/support including latest tutorials, courses, ways to support, and more! Check it out 🙂

👨‍💻 Get the FULL FREE PROJECT on GitHub: https://github.com/llamacademy/unity-csharp-basics-5


📚 Here are the resources I mentioned and/or brought up during the video 📚

🟠 Delegates: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/

🟠 Using Delegates: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/using-delegates

🟠 Unity Events: https://docs.unity3d.com/ScriptReference/Events.UnityEvent.htm

🟠 Singleton: https://en.wikipedia.org/wiki/Singleton_pattern


💸 Ongoing sales 💸

🟠 See all active asset sales on the Asset Store: https://assetstore.unity.com/?on_sale=true&orderBy=0&rows=96&clickref=1100lwtudvMJ&utm_source=partnerize&utm_medium=affiliate&utm_campaign=unity_affiliate&aid=1101l9QvC

🟠 Save 25% off your first Asset Store Order: https://prf.hn/click/camref:1101l9QvC/creativeref:1011l78340

🟠 Save up to 50% on NEW Assets: https://assetstore.unity.com/?new_sale=true&orderBy=1&aid=1101l9QvC


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


Connect on Social Media

Some links may be affiliate links, which at no additional cost to you, gives LlamAcademy a small portion of the purchase.