Advertisement
orfeasel

Delegates binding

Feb 4th, 2016
19,111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. //Declaring a delegate of MyDelegate type
  2. MyDelegate MyDel;
  3. //Binding a UFUNCTION to MyDel - this will not call the function just yet.
  4. MyDel.BindUFunction(this, FName("SomeFunction"));
  5.  
  6. //Calling the bound function of the delegate
  7. MyDel.Execute();
  8.  
  9. //Declaring a delegate of MyIntDelegate type
  10. MyIntDelegate IntDelegate;
  11.  
  12. //Binding two UFUNCTIONs to IntDelegate - this will not call any function just yet
  13. IntDelegate.BindUFunction(this, FName("IntFunction"));
  14. IntDelegate.BindUFunction(this, FName("SecondIntFunction"));
  15.  
  16. //Since the IntDelegate is a single-cast delegate it will only contain up to one function
  17. //In this case, the IntDelegate contains the last bound function
  18. IntDelegate.Execute(50);
  19.  
  20. //Declaring a delegate of MyIntMulticastDelegate type
  21. MyIntMulticastDelegate Del;
  22.  
  23. //Adding three UFUNCTIONs to the delegate - this will not call any function just yet
  24. Del.AddUFunction(this, FName("IntFunction"));
  25. Del.AddUFunction(this, FName("SecondIntFunction"));
  26. Del.AddUFunction(this, FName("ThirdIntFunction"));
  27.  
  28. //Calling all the bound functions with a value of 10
  29. Del.Broadcast(10);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement