Advertisement
kadyr

Untitled

Oct 23rd, 2021
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. using System;
  2. using UnityEngine;
  3.  
  4. public class DelegateTest:MonoBehaviour
  5. {
  6. private delegate void SimpleMethod();
  7.  
  8. private SimpleMethod simpleMethod;
  9.  
  10. private void Start()
  11. {
  12. simpleMethod += Method1;
  13. simpleMethod += Method2;
  14. simpleMethod += Method3;
  15. simpleMethod?.Invoke();
  16. simpleMethod -= Method2;
  17. simpleMethod?.Invoke();
  18.  
  19. }
  20.  
  21. private void Method1()
  22. {
  23. Debug.Log("met1");
  24. }
  25.  
  26. private void Method2()
  27. {
  28. Debug.Log("met2");
  29.  
  30. }
  31.  
  32. private void Method3()
  33. {
  34. Debug.Log("met3");
  35.  
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement