Documentation

Unity Engine

Unity Engine

UnityEvent<T0, T1, T2, T3>

Four argument version of UnityEvent.
Read time 1 minuteLast updated 17 days ago

Definition

public class UnityEvent<T0, T1, T2, T3> : 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, int> m_MyEvent; void Start() { if (m_MyEvent == null) m_MyEvent = new UnityEvent<int, int, int, int>(); m_MyEvent.AddListener(DoSomething); } void Update() { if (Input.anyKeyDown && m_MyEvent != null) { m_MyEvent.Invoke(5, 6, 7, 8); } } void DoSomething(int i, int j, int k, int l) { Debug.Log("Callback called " + i + ", " + j + ", " + k + ", " + l); }}
Note: UnityEvent can also be awaited in any async method.

Inheritance