There are third-party UnityEvent implementations that support multiple properties. Use one if you are comfortable with the dependency.
A built-in workaround is to serialize the data you want to pass from the UnityEvent in an intermediary.
using UnityEngine;
public class Destination : MonoBehaviour
{
public void Receive(string name, int value) => Debug.Log($"{name} called us with {value}!");
}I've also provided optional code that will automatically subscribe this script to any Button it's added to.
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
public class Intermediary : MonoBehaviour
{
// (1) The serialized data.
[SerializeField] private string _name;
[SerializeField] private int _value;
// A UnityEvent that can be invoked with the above data.
[SerializeField] private UnityEvent<string, int> _callback;
// (3) Invoke the UnityEvent with our data.
public void InvokeCallback() => _callback?.Invoke(_name, _value);
Editor code that subscribes the function to buttons when a new component is created./// <summary>
/// Editor code that subscribes the function to buttons when a new component is created.
/// </summary>
#if UNITY_EDITOR
private void Reset()
{
if (TryGetComponent(out Button button))
UnityEditor.Events.UnityEventTools.AddPersistentListener(button.onClick, InvokeCallback);
}
#endif
}