Unity 事件2

例子1:

using UnityEngine;
using System;

public class ClassA : MonoBehaviour {
 public EventHandler<EventArgs> MouseEvent { get; set; } 
 void Start()
 {
  this.MouseEvent = OnTest;
 }
 void OnGUI()
 {
  if(GUI.Button(new Rect(0,0,200,200),"1111"))
  {
      MouseEvent(gameObject,null);
  }
 }
 void OnTest(object sender,EventArgs e)
 {
  Debug.Log("-------");
 }
}


 

你可能感兴趣的:(Unity 事件2)