代理,delegate,用法如下:
using UnityEngine;
using UnityEngine.Events;
namespace GFrame
{
/// <summary>
///
/// author: Gong
/// </summary>
public class GInteract
{
public delegate void CallBackSetValue(bool value);
public CallBackSetValue callbackSetValue;
public void Do()
{
callbackSetValue?.Invoke(true);
}
private static GInteract __inst;
public static GInteract Instance
{
get
{
if (null == __inst)
{
__inst = new GInteract();
}
return __inst;
}
}
}
}
在其他类中这样调用:
private void exFunc()
{
GInteract.Instance.callbackSetValue = _CallBack;
GInteract.Instance.Do();
}
private void _CallBack(bool value)
{
}