using UnityEngine;using System.Collections;using System;public class eventTest : MonoBehaviour { private event ActiononClick; private uint i = 0; // Use this for initialization void Start () { onClick += OnClick; onClick += OnClick; onClick += OnClick; onClick += OnClick; onClick += OnClick; onClick += OnClick; onClick += OnClick2; } // Update is called once per frame void Update () { if (Input.GetMouseButtonUp(0)) { Delegate[] list = onClick.GetInvocationList(); Debug.Log("存在在" + Array.IndexOf(list, (Action )OnClick2)); //for (int i = 0; i < list.Length; i++ ) //{ // if(list[i].Equals((Action )OnClick)) // { // } //} } } private void OnClick(uint i) { Debug.Log(i); i++; } private void OnClick2(uint i) { }}
不存在输出为-1,存在输出为大于0的index