Good afternoon. I have a list of components, in OnEnable I subscribe to the event of these components. How to determine which component in the list triggered an event?
public class Example : MonoBehaviour
{
[SerializeField] private List<Components> _components;
private Component _currentComponent;
private void OnEnable()
{
foreach (var component in _components)
{
component.Event+= Method;
}
}
private void OnDisable()
{
foreach (var component in _components)
{
component.Event-= Method;
}
}
private void Method()
{
_currentComponent = ???????
}
}
The only solution I found is when calling an event in the “Component” script via transform.GetComponent to pass data, but it seems to be costly