Learning About Delegates
While researching into Behaviour Trees (BT) in Unity I kept coming across the "delegate" keyword so I decided to research further into the use of delegates.
Delegates can be "used to pass methods as arguments to other methods" (Docs.microsoft.com, 2018) and if you read further through the Microsoft documentation on delegates it further clarifies the similarity to "C++ function pointers, but delegates are fully object-oriented, and unlike C++ pointers to member functions, delegates encapsulate both an object instance and a method." (Docs.microsoft.com, 2018).
As shown in the Unity scripting tutorial on delegates they are created by using the keyword "delegate void MyDelegate(int num);" (Unity, 2018) and shows how the delegate variable can be reassigned to different methods however they must have the same return type.
I also watched a couple of videos on YouTube about delegates, and although I feel like I now understand them, I'm not 100% comfortable with when and how to use them so I have decided to find another way to complete my BT framework.
Reference List
[1] Unity. (2018). Delegates - Unity. Available at: https://unity3d.com/learn/tutorials/topics/scripting/delegates [Accessed 19/11/2018].
[2] YouTube. (2017). Unity3D - Delegates and Actions Introduction. [online] Available at: https://www.youtube.com/watch?v=klwEhouBKTc [Accessed 20/11/2018]
[3] Docs.microsoft.com. (2018). Delegates - C# Programming Guide. [online] Available at: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/ [Accessed 19/11/2018].
[4] Lague, S. (2016). [C#] Delegates and Events (E01: delegates). [online] YouTube. Available at: https://www.youtube.com/watch?v=G5R4C8BLEOc [Accessed 20/11/2018].
Delegates can be "used to pass methods as arguments to other methods" (Docs.microsoft.com, 2018) and if you read further through the Microsoft documentation on delegates it further clarifies the similarity to "C++ function pointers, but delegates are fully object-oriented, and unlike C++ pointers to member functions, delegates encapsulate both an object instance and a method." (Docs.microsoft.com, 2018).
As shown in the Unity scripting tutorial on delegates they are created by using the keyword "delegate void MyDelegate(int num);" (Unity, 2018) and shows how the delegate variable can be reassigned to different methods however they must have the same return type.
I also watched a couple of videos on YouTube about delegates, and although I feel like I now understand them, I'm not 100% comfortable with when and how to use them so I have decided to find another way to complete my BT framework.
Reference List
[1] Unity. (2018). Delegates - Unity. Available at: https://unity3d.com/learn/tutorials/topics/scripting/delegates [Accessed 19/11/2018].
[2] YouTube. (2017). Unity3D - Delegates and Actions Introduction. [online] Available at: https://www.youtube.com/watch?v=klwEhouBKTc [Accessed 20/11/2018]
[3] Docs.microsoft.com. (2018). Delegates - C# Programming Guide. [online] Available at: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/ [Accessed 19/11/2018].
[4] Lague, S. (2016). [C#] Delegates and Events (E01: delegates). [online] YouTube. Available at: https://www.youtube.com/watch?v=G5R4C8BLEOc [Accessed 20/11/2018].