当前位置:网站首页>A simple example of delegate usage
A simple example of delegate usage
2022-07-07 10:48:00 【HCC2017】
public delegate void LogDelegate(string log); // Definition The delegate name is LogDelegate, With a string Parametric Delegate type
public static LogDelegate LogEvent; // Declare the delegate object , The delegate instance is LogEvent
public static void OnLogEvent(string log)
{
if (LogEvent != null)
{
LogEvent(log);
}
}
}
/// <summary>
/// Add call event , The delegate
/// </summary>
class TextDelegate : MonoBehaviour
{
void Start()
{
TextDelegate2.LogEvent += Cat;
TextDelegate2.LogEvent += Dog;
TextDelegate2.OnLogEvent(" Feed the small animals ");// Send callback information to the function
}
void Cat(string log)
{
Debug.Log(" cat :" + log);
}
void Dog(string log)
{
Debug.Log(" Wang Wang Wang :" + log);
}
}
边栏推荐
猜你喜欢
What are the contents of the intermediate soft test, the software designer test, and the test outline?
Leetcode-560: subarray with sum K
软考中级,软件设计师考试那些内容,考试大纲什么的?
SQL Server knowledge gathering 9: modifying data
如何顺利通过下半年的高级系统架构设计师?
The gun startles the dragon, and the crowd "locks" Zhou Zhi
China Southern Airlines pa3.1
Applet jump to H5, configure business domain name experience tutorial
Application of OpenGL gllightfv function and related knowledge of light source
Use load_ decathlon_ Datalist (Monai) fast loading JSON data
随机推荐
555电路详解
China Southern Airlines pa3.1
深入理解Apache Hudi异步索引机制
Some superficial understanding of word2vec
想考中级软考,一般需要多少复习时间?
1324: [example 6.6] integer interval
OpenGL glLightfv 函数的应用以及光源的相关知识
5个chrome简单实用的日常开发功能详解,赶快解锁让你提升更多效率!
Unable to open kernel device '\.\vmcidev\vmx': operation completed successfully. Reboot after installing vmware workstation? Module "devicepoweron" failed to start. Failed to start the virtual machine
施努卡:机器人视觉抓取工作原理 机器视觉抓取
When do you usually get grades in the soft exam? Online pedaling?
优雅的 Controller 层代码
IIC Basics
The mobile terminal automatically adjusts the page content and font size by setting rem
软考中级有用吗??
在线硬核工具
成为优秀的TS体操高手 之 TS 类型体操前置知识储备
Multisim--软件相关使用技巧
无法打开内核设备“\\.\VMCIDev\VMX”: 操作成功完成。是否在安装 VMware Workstation 后重新引导? 模块“DevicePowerOn”启动失败。 未能启动虚拟机。
[email protected] can help us get the log object quickly