using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour {
public delegate void VoidDeleage();
public VoidDeleage OnTest;
public delegate void Del(int index);
public Del OnTest2;
int index = 0;
void Start()
{
OnTest = Call;
OnTest2 = Call2;
}
void OnGUI()
{
//开始按钮
if (GUI.Button(new Rect(0, 10, 100, 30), "Test"))
{
if (OnTest != null)//这种事无参数
{
OnTest();
}
}
if (GUI.Button(new Rect(0, 60, 100, 30), "Test2"))
{
index++;
if (OnTest2 != null)//这样就可以传递参数
{
OnTest2(index);
}
}
}
void Call()
{
Debug.Log("Test");
}
void Call2(int index)
{
Debug.Log("Test2参数:" + index);
}
}
using System.Collections;
public class Test : MonoBehaviour {
public delegate void VoidDeleage();
public VoidDeleage OnTest;
public delegate void Del(int index);
public Del OnTest2;
int index = 0;
void Start()
{
OnTest = Call;
OnTest2 = Call2;
}
void OnGUI()
{
//开始按钮
if (GUI.Button(new Rect(0, 10, 100, 30), "Test"))
{
if (OnTest != null)//这种事无参数
{
OnTest();
}
}
if (GUI.Button(new Rect(0, 60, 100, 30), "Test2"))
{
index++;
if (OnTest2 != null)//这样就可以传递参数
{
OnTest2(index);
}
}
}
void Call()
{
Debug.Log("Test");
}
void Call2(int index)
{
Debug.Log("Test2参数:" + index);
}
}