UnityEvent<T0, T1, T2>
Three argument version of UnityEvent.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Class
- Namespace: UnityEngine.Events
- Assembly: UnityEngine.CoreModule
- Inherits from: UnityEventBase
- Implements: ISerializationCallbackReceiver
public class UnityEvent<T0, T1, T2> : UnityEventBase, ISerializationCallbackReceiver
Remarks
Generics are supported, specify type parameters on initialization as shown in the example. Refer to Configure callbacks in the Inspector for details on configuring callbacks in the Inspector window.
using UnityEngine;using UnityEngine.Events;public class ExampleClass : MonoBehaviour{ UnityEvent<int, int, int> m_MyEvent; void Start() { if (m_MyEvent == null) m_MyEvent = new UnityEvent<int, int, int>(); m_MyEvent.AddListener(DoSomething); } void Update() { if (Input.anyKeyDown && m_MyEvent != null) { m_MyEvent.Invoke(5, 6, 7); } } void DoSomething(int i, int j, int k) { Debug.Log("Callback called " + i + ", " + j + ", " + k); }}
Note: UnityEvent can also be awaited in any async method.