More to study
5 minutes Guide of C# Action with Examples
// event input
public UnityEvent<bool> IsInteractable;
// event output
public UnityEvent<bool> IsInteractableInverseValue;
// action output
public UnityAction<bool> action;
private void Start()
{
// send value directly on event
IsInteractable.AddListener(IsInteractableInverseValue.Invoke);
// send value directly on action
IsInteractable.AddListener(action.Invoke);
// send value inverse on event with lambda
IsInteractable.AddListener((value)=>
{
IsInteractableInverseValue?.Invoke(!value);
});
// send value inverse on action with lambda
IsInteractable.AddListener((value) =>
{
action?.Invoke(!value);
});
// i can utilize with all class or variable
eventInputClassExample.AddListener(actionToInvokeClassExample.Invoke);
// or
eventInputClassExample.AddListener((slideValue)=>
{
actionToInvokeClassExample?.Invoke(slideValue);
});
}
public UnityEvent<Slide> eventInputClassExample;
public UnityAction<Slide> actionToInvokeClassExample;