Answers for "unity delegate event"

C#
2

unity delegate event

//Defining Delegate
public delegate void OnButtonClickDelegate();
public static OnButtonClickDelegate buttonClickDelegate;
 
//Subscribing to delegate
 
// eg. of Singlecast
buttonClickDelegate = myCustomMethod;
 
//eg. of Multicast Delegate
buttonClickDelegate += myCustomMethod;
buttonClickDelegate +=myAnotherCustomMethod
 
//Calling Delegates
buttonClickDelegate();
 
//UnSubscribing to Delegate
buttonClickDelegate -= myCustomMethod;
buttonClickDelegate -=myAnotherCustomMethod
Posted by: Guest on July-01-2021

C# Answers by Framework

Browse Popular Code Answers by Language