@ CloudGuan
@ Copyright 2016 Cloud Guan, Inc. All Rights Reserved.
Delegates System In Unreal Engine
What is delegates in Unreal Engine?And How use it?
Delegates allow you to call member functions on C++ objects in a generic, yet type-safe way. Using delegates, you can dynamically bind to a member function of an arbitrary object, then call functions on the object, even if the caller does not know the object’s type.
代理机制允许你可以类型安全的使用C++类的成员函数,还可以自动的绑定成员函数到任意的变量上,然后通过这个变量来调用,我们这个变量甚至不需要知道它的类型。
It is perfectly safe to copy delegate objects. Delegates can be passed around by value but this is generally not recommended since they do have to allocate memory on the heap. You should always pass delegates by reference when possible.
拷贝代理变量是完全安全的,代理可以使用值传递,但是因为他们会在堆上分配内存的原因,所以不建议这样做。最好是通过引用传递的方式来传递这个值
Both single-cast and multi-cast delegates are supported, as well as “dynamic” delegates which can be safely serialized to disk.
代理支持单播和广播,自动的代理会更加的安全在序列化到磁盘的时候
Type of Delegate
这是可以用于普通类型和函数的代理,没有特别要求使用UCALSS标记宏标记的类,基本声明方式如下表所示: