当前位置:网站首页>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);
}
}
边栏推荐
- Openinstall and Hupu have reached a cooperation to mine the data value of sports culture industry
- Long list performance optimization scheme memo
- Kotlin realizes wechat interface switching (fragment exercise)
- 【安装系统】U盘安装系统教程,使用UltraISO制作U盘启动盘
- Schnuka: working principle of robot visual grasping machine visual grasping
- Mendeley -- a free document management tool that automatically inserts references into papers
- 使用Tansformer分割三维腹部多器官--UNETR实战
- [recommendation system 01] rechub
- [detailed explanation of Huawei machine test] tall and short people queue up
- Network engineer test questions and answers in May of the first half of 2022
猜你喜欢
Applet jump to H5, configure business domain name experience tutorial
无法打开内核设备“\\.\VMCIDev\VMX”: 操作成功完成。是否在安装 VMware Workstation 后重新引导? 模块“DevicePowerOn”启动失败。 未能启动虚拟机。
ADB utility commands (network package, log, tuning related)
[recommendation system 01] rechub
Différences entre les contraintes monotones et anti - monotones
深入理解Apache Hudi异步索引机制
2022年7月10日“五心公益”活动通知+报名入口(二维码)
枪出惊龙,众“锁”周之
Socket communication principle and Practice
Using tansformer to segment three-dimensional abdominal multiple organs -- actual battle of unetr
随机推荐
PHP \ newline cannot be output
Trajectory planning for multi-robot systems: Methods and applications 综述阅读笔记
IIC Basics
想考中级软考,一般需要多少复习时间?
P1223 queuing for water /1319: [example 6.1] queuing for water
Schnuka: machine vision positioning technology machine vision positioning principle
The difference between monotonicity constraint and anti monotonicity constraint
原型与原型链
What is an intermediate network engineer? What is the main test and what is the use?
【推荐系统 02】DeepFM、YoutubeDNN、DSSM、MMOE
软考信息处理技术员有哪些备考资料与方法?
2022年7月10日“五心公益”活动通知+报名入口(二维码)
施努卡:机器视觉定位技术 机器视觉定位原理
软考中级,软件设计师考试那些内容,考试大纲什么的?
JS实现链式调用
2022年上半年5月网络工程师试题及答案
Différences entre les contraintes monotones et anti - monotones
MONAI版本更新到 0.9 啦,看看有什么新功能
【PyTorch 07】 动手学深度学习——chapter_preliminaries/ndarray 习题动手版
Leetcode-304: two dimensional area and retrieval - matrix immutable