UnityEvent 2個參數

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
[System.Serializable]
public class MyEvent : UnityEvent<int, int>
{

}
public class EventTest2 : MonoBehaviour
{
     MyEvent myEvent;
    // Use this for initialization
    void Start () {
        if (myEvent == null)
            myEvent = new MyEvent();
        myEvent.AddListener(Ping);
    }
    
    // Update is called once per frame
    void Update () {
        if (Input.anyKey && myEvent != null)
        {
            myEvent.Invoke(1,2);
        }
    }
    void Ping(int index0 ,int index1)
    {
        Debug.Log("這個是第一個參數" + index0 + "這個是第二個參數" + index1);
    }
}
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章